diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseContext.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseContext.java index 4f784d1..564c1c9 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseContext.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseContext.java @@ -87,6 +87,7 @@ // reducer private Map prunedPartitions; private Map viewAliasToInput; + private Map tabNameToTabObject; /** * The lineage information. @@ -162,6 +163,7 @@ public ParseContext( Context ctx, HashMap idToTableNameMap, int destTableId, UnionProcContext uCtx, List> listMapJoinOpsNoReducer, Map prunedPartitions, + Map tabNameToTabObject, HashMap opToSamplePruner, GlobalLimitCtx globalLimitCtx, HashMap nameToSplitSample, @@ -185,6 +187,7 @@ public ParseContext( this.uCtx = uCtx; this.listMapJoinOpsNoReducer = listMapJoinOpsNoReducer; this.prunedPartitions = prunedPartitions; + this.tabNameToTabObject = tabNameToTabObject; this.opToSamplePruner = opToSamplePruner; this.nameToSplitSample = nameToSplitSample; this.globalLimitCtx = globalLimitCtx; @@ -572,4 +575,8 @@ public boolean isNeedViewColumnAuthorization() { public void setNeedViewColumnAuthorization(boolean needViewColumnAuthorization) { this.needViewColumnAuthorization = needViewColumnAuthorization; } + + public Map getTabNameToTabObject() { + return tabNameToTabObject; + } } 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 d9db1d5..95c2994 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 @@ -324,7 +324,7 @@ protected AnalyzeRewriteContext analyzeRewrite; // A mapping from a tableName to a table object in metastore. - Map tableNameToMetaDataTableObject; + Map tabNameToTabObject; // The tokens we should ignore when we are trying to do table masking. private final Set ignoredTokens = Sets.newHashSet(HiveParser.TOK_GROUPBY, @@ -359,6 +359,7 @@ public SemanticAnalyzer(HiveConf conf) throws SemanticException { listMapJoinOpsNoReducer = new ArrayList>(); groupOpToInputTables = new HashMap>(); prunedPartitions = new HashMap(); + tabNameToTabObject = new HashMap(); unparseTranslator = new UnparseTranslator(conf); autogenColAliasPrfxLbl = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_AUTOGEN_COLUMNALIAS_PREFIX_LABEL); @@ -371,7 +372,7 @@ public SemanticAnalyzer(HiveConf conf) throws SemanticException { viewAliasToInput = new HashMap(); noscan = partialscan = false; tableMask = new TableMask(this, conf); - tableNameToMetaDataTableObject = new HashMap<>(); + tabNameToTabObject = new HashMap<>(); } @Override @@ -380,6 +381,7 @@ protected void reset(boolean clearPartsCache) { if(clearPartsCache) { prunedPartitions.clear(); } + tabNameToTabObject.clear(); loadTableWork.clear(); loadFileWork.clear(); topOps.clear(); @@ -429,6 +431,7 @@ public void initParseCtx(ParseContext pctx) { uCtx = pctx.getUCtx(); listMapJoinOpsNoReducer = pctx.getListMapJoinOpsNoReducer(); prunedPartitions = pctx.getPrunedPartitions(); + tabNameToTabObject = pctx.getTabNameToTabObject(); fetchTask = pctx.getFetchTask(); setLineageInfo(pctx.getLineageInfo()); } @@ -440,7 +443,7 @@ public ParseContext getParseContext() { new HashSet(joinContext.keySet()), new HashSet(smbMapJoinContext.keySet()), loadTableWork, loadFileWork, ctx, idToTableNameMap, destTableId, uCtx, - listMapJoinOpsNoReducer, prunedPartitions, + listMapJoinOpsNoReducer, prunedPartitions, tabNameToTabObject, opToSamplePruner, globalLimitCtx, nameToSplitSample, inputs, rootTasks, opToPartToSkewedPruner, viewAliasToInput, reduceSinkOperatorsAddedByEnforceBucketingSorting, analyzeRewrite, tableDesc, queryProperties, viewProjectToTableSchema); @@ -1606,7 +1609,7 @@ public boolean doPhase1(ASTNode ast, QB qb, Phase1Ctx ctx_1, PlannerContext plan } Table table = null; try { - table = db.getTable(tableName); + table = this.getTableObjectByName(tableName); } catch (HiveException ex) { throw new SemanticException(ex); } @@ -10344,13 +10347,13 @@ void setInsertToken(ASTNode ast, boolean isTmpFileDest) { } } - private Table getMetaDataTableObjectByName(String tableName) throws HiveException { - if (!tableNameToMetaDataTableObject.containsKey(tableName)) { + private Table getTableObjectByName(String tableName) throws HiveException { + if (!tabNameToTabObject.containsKey(tableName)) { Table table = db.getTable(tableName); - tableNameToMetaDataTableObject.put(tableName, table); + tabNameToTabObject.put(tableName, table); return table; } else { - return tableNameToMetaDataTableObject.get(tableName); + return tabNameToTabObject.get(tableName); } } @@ -10400,7 +10403,7 @@ private void walkASTMarkTABREF(ASTNode ast, Set cteAlias) String replacementText = null; Table table = null; try { - table = getMetaDataTableObjectByName(tabIdName); + table = getTableObjectByName(tabIdName); } catch (HiveException e) { throw new SemanticException("Table " + tabIdName + " is not found."); } @@ -10636,7 +10639,7 @@ void analyzeInternal(ASTNode ast, PlannerContext plannerCtx) throws SemanticExce new HashSet(joinContext.keySet()), new HashSet(smbMapJoinContext.keySet()), loadTableWork, loadFileWork, ctx, idToTableNameMap, destTableId, uCtx, - listMapJoinOpsNoReducer, prunedPartitions, opToSamplePruner, + listMapJoinOpsNoReducer, prunedPartitions, tabNameToTabObject, opToSamplePruner, globalLimitCtx, nameToSplitSample, inputs, rootTasks, opToPartToSkewedPruner, viewAliasToInput, reduceSinkOperatorsAddedByEnforceBucketingSorting, analyzeRewrite, tableDesc, queryProperties, viewProjectToTableSchema); @@ -11667,7 +11670,7 @@ private void validateCreateView(CreateViewDesc createVwDesc) Set tableAliases = qb.getTabAliases(); for (String alias : tableAliases) { try { - Table table = db.getTable(qb.getTabNameForAlias(alias)); + Table table = this.getTableObjectByName(qb.getTabNameForAlias(alias)); if (table.isTemporary()) { throw new SemanticException("View definition references temporary table " + alias); } @@ -11870,7 +11873,7 @@ private void validateAnalyzeNoscan(ASTNode tree) throws SemanticException { String tableName = getUnescapedName((ASTNode) tree.getChild(0).getChild(0)); Table tbl; try { - tbl = db.getTable(tableName); + tbl = this.getTableObjectByName(tableName); } catch (InvalidTableException e) { throw new SemanticException(ErrorMsg.INVALID_TABLE.getMsg(tableName), e); } @@ -11899,7 +11902,7 @@ private void validateAnalyzePartialscan(ASTNode tree) throws SemanticException { String tableName = getUnescapedName((ASTNode) tree.getChild(0).getChild(0)); Table tbl; try { - tbl = db.getTable(tableName); + tbl = this.getTableObjectByName(tableName); } catch (InvalidTableException e) { throw new SemanticException(ErrorMsg.INVALID_TABLE.getMsg(tableName), e); } catch (HiveException e) { diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java index 8e64a0b..f7d7a40 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java @@ -399,7 +399,7 @@ public ParseContext getParseContext(ParseContext pCtx, List