Repository: hive Updated Branches: refs/heads/master 9a9f7de87 -> 00145ee85
HIVE-18577 : SemanticAnalyzer.validate has some pointless metastore calls (Sergey Shelukhin, reviewed by Ashutosh Chauhan) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/00145ee8 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/00145ee8 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/00145ee8 Branch: refs/heads/master Commit: 00145ee859f93bb5c341e73a523e9a6062015bf6 Parents: 9a9f7de Author: sergey <[email protected]> Authored: Tue Jan 30 13:20:48 2018 -0800 Committer: sergey <[email protected]> Committed: Tue Jan 30 13:21:58 2018 -0800 ---------------------------------------------------------------------- .../hadoop/hive/ql/parse/SemanticAnalyzer.java | 54 ++++++++------------ .../ql/parse/UpdateDeleteSemanticAnalyzer.java | 1 + 2 files changed, 22 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/00145ee8/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java ---------------------------------------------------------------------- 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 83dfb47..69d4fa5 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 @@ -11944,6 +11944,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { @Override public void validate() throws SemanticException { LOG.debug("validation start"); + boolean wasAcidChecked = false; // Validate inputs and outputs have right protectmode to execute the query for (ReadEntity readEntity : getInputs()) { ReadEntity.Type type = readEntity.getType(); @@ -11963,7 +11964,10 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { } if (tbl != null && AcidUtils.isTransactionalTable(tbl)) { transactionalInQuery = true; - checkAcidTxnManager(tbl); + if (!wasAcidChecked) { + checkAcidTxnManager(tbl); + } + wasAcidChecked = true; } } @@ -11976,6 +11980,13 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { try { Partition usedp = writeEntity.getPartition(); Table tbl = usedp.getTable(); + if (AcidUtils.isTransactionalTable(tbl)) { + transactionalInQuery = true; + if (!wasAcidChecked) { + checkAcidTxnManager(tbl); + } + wasAcidChecked = true; + } LOG.debug("validated " + usedp.getName()); LOG.debug(usedp.getTable().getTableName()); @@ -11989,6 +12000,15 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { conflictingArchive); throw new SemanticException(message); } + } else if (type == WriteEntity.Type.TABLE) { + Table tbl = writeEntity.getTable(); + if (AcidUtils.isTransactionalTable(tbl)) { + transactionalInQuery = true; + if (!wasAcidChecked) { + checkAcidTxnManager(tbl); + } + wasAcidChecked = true; + } } if (type != WriteEntity.Type.TABLE && @@ -11996,38 +12016,6 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { LOG.debug("not validating writeEntity, because entity is neither table nor partition"); continue; } - - Table tbl; - Partition p; - - - if (type == WriteEntity.Type.PARTITION) { - Partition inputPartition = writeEntity.getPartition(); - - // If it is a partition, Partition's metastore is not fetched. We - // need to fetch it. - try { - p = Hive.get().getPartition( - inputPartition.getTable(), inputPartition.getSpec(), false); - if (p != null) { - tbl = p.getTable(); - } else { - // if p is null, we assume that we insert to a new partition - tbl = inputPartition.getTable(); - } - } catch (HiveException e) { - throw new SemanticException(e); - } - } - else { - LOG.debug("Not a partition."); - tbl = writeEntity.getTable(); - } - - if (tbl != null && AcidUtils.isTransactionalTable(tbl)) { - transactionalInQuery = true; - checkAcidTxnManager(tbl); - } } boolean reworkMapredWork = HiveConf.getBoolVar(this.conf, http://git-wip-us.apache.org/repos/asf/hive/blob/00145ee8/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java index c632a77..a660747 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java @@ -773,6 +773,7 @@ public class UpdateDeleteSemanticAnalyzer extends SemanticAnalyzer { } } outputs.removeAll(toRemove); + // TODO: why is this like that? for(ReadEntity re : partitionsRead) { for(WriteEntity original : toRemove) { //since we may have both Update and Delete branches, Auth needs to know
