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 42a7ab9..ec1567e 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 @@ -252,7 +252,7 @@ // Max characters when auto generating the column name with func name private static final int AUTOGEN_COLALIAS_PRFX_MAXLENGTH = 20; - private static final String VALUES_TMP_TABLE_NAME_PREFIX = "Values__Tmp__Table__"; + public static final String VALUES_TMP_TABLE_NAME_PREFIX = "Values__Tmp__Table__"; static final String MATERIALIZATION_MARKER = "$MATERIALIZATION"; @@ -2035,8 +2035,11 @@ private void getMetaData(QB qb, ReadEntity parentInput) } ReadEntity parentViewInfo = PlanUtils.getParentViewInfo(getAliasId(alias, qb), viewAliasToInput); - PlanUtils.addInput(inputs, - new ReadEntity(tab, parentViewInfo, parentViewInfo == null),mergeIsDirect); + // Temporary tables created during the execution are not the input sources + if (!PlanUtils.isValuesTempTable(alias)) { + PlanUtils.addInput(inputs, + new ReadEntity(tab, parentViewInfo, parentViewInfo == null),mergeIsDirect); + } } LOG.info("Get metadata for subqueries"); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java index b15ad34..1c0ac1e 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java @@ -1024,6 +1024,15 @@ public static void addExprToStringBuffer(ExprNodeDesc expr, Appendable sb, boole } } + /** + * Check if the table is the temporary table created by VALUES() syntax + * @param tableName table name + * @return + */ + public static boolean isValuesTempTable(String tableName) { + return tableName.toLowerCase().startsWith(SemanticAnalyzer.VALUES_TMP_TABLE_NAME_PREFIX.toLowerCase()); + } + public static void addPartitionInputs(Collection parts, Collection inputs, ReadEntity parentViewInfo, boolean isDirectRead) { // Store the inputs in a HashMap since we can't get a ReadEntity from inputs since it is @@ -1036,6 +1045,11 @@ public static void addPartitionInputs(Collection parts, Collection