diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index da962109ad63eebaaa0503a7707ee8c87c4b1a30..edfe01f4c71a63f7d3faa2a9d3f57a8cd0673a65 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -1844,7 +1844,7 @@ private Path getStrongestEncryptedTablePath(QB qb) throws HiveException { try { if (strongestPath == null) { strongestPath = tablePath; - } else if (tablePath.toUri().getScheme().equals("hdfs") + } else if ("hdfs".equals(tablePath.toUri().getScheme()) && isPathEncrypted(tablePath) && comparePathKeyStrength(tablePath, strongestPath) > 0) { @@ -1877,10 +1877,10 @@ private Path getStagingDirectoryPathname(QB qb) throws HiveException { // Looks for the most encrypted table location (if there is one) tablePath = getStrongestEncryptedTablePath(qb); - if (tablePath != null) { + if (tablePath != null && isPathEncrypted(tablePath)) { // Only HDFS paths can be checked for encryption - if (tablePath.toUri().getScheme().equals("hdfs")) { - if (isPathReadOnly(tablePath) && isPathEncrypted(tablePath)) { + if ("hdfs".equals(tablePath.toUri().getScheme())) { + if (isPathReadOnly(tablePath)) { Path tmpPath = ctx.getMRTmpPath(); if (comparePathKeyStrength(tablePath, tmpPath) < 0) { throw new HiveException("Read-only encrypted tables cannot be read " + @@ -1889,6 +1889,8 @@ private Path getStagingDirectoryPathname(QB qb) throws HiveException { stagingPath = tmpPath; } } + } else { + LOG.debug("Encryption is not applicable to table path " + tablePath.toString()); } if (stagingPath == null) { diff --git a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java index e5f609cf4219e503dec01117cc8cfe3a12f55e75..eb0f087bb379be8aab66ff6e4940345bcef628dd 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java @@ -384,8 +384,10 @@ public boolean isAutoCommit() { if (hdfsEncryptionShim == null) { try { FileSystem fs = FileSystem.get(conf); - if (fs.getUri().getScheme().equals("hdfs")) { + if ("hdfs".equals(fs.getUri().getScheme())) { hdfsEncryptionShim = ShimLoader.getHadoopShims().createHdfsEncryptionShim(fs, conf); + } else { + LOG.info("Could not get hdfsEncryptionShim, it is only applicable to hdfs filesystem."); } } catch (Exception e) { throw new HiveException(e);