diff --git a/fe/src/main/java/org/apache/impala/catalog/HdfsTable.java b/fe/src/main/java/org/apache/impala/catalog/HdfsTable.java index dba18957b5..d8b789d450 100644 --- a/fe/src/main/java/org/apache/impala/catalog/HdfsTable.java +++ b/fe/src/main/java/org/apache/impala/catalog/HdfsTable.java @@ -38,6 +38,8 @@ import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.permission.FsAction; +import org.apache.hadoop.security.AccessControlException; import org.apache.hadoop.fs.RemoteIterator; import org.apache.hadoop.hive.common.ValidTxnList; import org.apache.hadoop.hive.common.ValidWriteIdList; @@ -833,16 +835,23 @@ private static TAccessLevel getAvailableAccessLevel(String tableName, Preconditions.checkNotNull(location); FileSystem fs = location.getFileSystem(CONF); + String hdfsAuthClass = CONF.get("dfs.namenode.inode.attributes.provider.class"); + boolean hdfsRangerEnabled = false; + + if (hdfsAuthClass != null && hdfsAuthClass.equals("org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer")) { + hdfsRangerEnabled = true; + } + if (assumeReadWriteAccess(fs)) return TAccessLevel.READ_WRITE; while (location != null) { try { FsPermissionChecker.Permissions perms = permCache.getPermissions(location); - if (perms.canReadAndWrite()) { + if (hdfsRangerEnabled ? checkAccess(location, fs, FsAction.getFsAction("rw-")) : perms.canReadAndWrite()) { return TAccessLevel.READ_WRITE; - } else if (perms.canRead()) { + } else if (hdfsRangerEnabled ? checkAccess(location, fs, FsAction.getFsAction("r--")) : perms.canRead()) { return TAccessLevel.READ_ONLY; - } else if (perms.canWrite()) { + } else if (hdfsRangerEnabled ? checkAccess(location, fs, FsAction.getFsAction("-w-")) : perms.canWrite()) { return TAccessLevel.WRITE_ONLY; } return TAccessLevel.NONE; @@ -3158,4 +3167,14 @@ public boolean isParquetTable() { } return true; } + + public static boolean checkAccess(Path path, FileSystem fs, FsAction action) throws IOException { + try { + fs.access(path, action); + } catch (AccessControlException e) { + return false; + } + return true; + } + } diff --git a/fe/src/main/java/org/apache/impala/service/Frontend.java b/fe/src/main/java/org/apache/impala/service/Frontend.java index b2124a1a42..46a56e7b32 100644 --- a/fe/src/main/java/org/apache/impala/service/Frontend.java +++ b/fe/src/main/java/org/apache/impala/service/Frontend.java @@ -2084,6 +2084,7 @@ private TExecRequest getTExecRequest(PlanCtx planCtx, EventSequence timeline) + planCtx.compilationState_.getAvailableCoresPerNode() + " cores per node."); String retryMsg = ""; + String errorMsg = ""; while (true) { try { req = doCreateExecRequest(planCtx, timeline); @@ -2103,7 +2104,11 @@ private TExecRequest getTExecRequest(PlanCtx planCtx, EventSequence timeline) LOG.warn("Retrying plan of query {}: {} (retry #{} of {})", queryCtx.client_request.stmt, retryMsg, attempt, INCONSISTENT_METADATA_NUM_RETRIES); - } + } catch (AnalysisException e) { + errorMsg = e.getMessage(); + LOG.warn("Analysis Exception query {}: {}", + queryCtx.client_request.stmt, errorMsg); + throw e; } // Counters about this group set.