diff --git common/src/java/org/apache/hadoop/hive/conf/HiveConf.java common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index 15fce1e..0a99c38 100644 --- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -468,6 +468,8 @@ HIVEUSEEXPLICITRCFILEHEADER("hive.exec.rcfile.use.explicit.header", true), + HIVESTRICTCOLUMNREFKEY("hive.column.reference.key.strict", true), + HIVESKEWJOIN("hive.optimize.skewjoin", false), HIVECONVERTJOIN("hive.auto.convert.join", false), HIVESKEWJOINKEY("hive.skewjoin.key", 100000), diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index 6e3aafc..cc5a8a4 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -1674,7 +1674,7 @@ private Integer genColListRegex(String colRegex, String tabAlias, ExprNodeColumnDesc expr = new ExprNodeColumnDesc(colInfo.getType(), name, colInfo.getTabAlias(), colInfo.getIsVirtualCol(), colInfo.isSkewedCol()); - if (subQuery) { + if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVESTRICTCOLUMNREFKEY) && subQuery) { output.checkColumn(tmp[0], tmp[1]); } col_list.add(expr); diff --git ql/src/test/queries/clientpositive/ambiguous_col0.q ql/src/test/queries/clientpositive/ambiguous_col0.q new file mode 100644 index 0000000..b99988e --- /dev/null +++ ql/src/test/queries/clientpositive/ambiguous_col0.q @@ -0,0 +1,3 @@ +set hive.column.reference.key.strict=false; +-- TOK_ALLCOLREF +explain select * from (select * from (select * from src) a join (select * from src1) b on (a.key = b.key)) t; diff --git ql/src/test/results/clientpositive/ambiguous_col0.q.out ql/src/test/results/clientpositive/ambiguous_col0.q.out new file mode 100644 index 0000000..b7c5f65 --- /dev/null +++ ql/src/test/results/clientpositive/ambiguous_col0.q.out @@ -0,0 +1,93 @@ +PREHOOK: query: -- TOK_ALLCOLREF +explain select * from (select * from (select * from src) a join (select * from src1) b on (a.key = b.key)) t +PREHOOK: type: QUERY +POSTHOOK: query: -- TOK_ALLCOLREF +explain select * from (select * from (select * from src) a join (select * from src1) b on (a.key = b.key)) t +POSTHOOK: type: QUERY +ABSTRACT SYNTAX TREE: + (TOK_QUERY (TOK_FROM (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_JOIN (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME src))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)))) a) (TOK_SUBQUERY (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME src1))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)))) b) (= (. (TOK_TABLE_OR_COL a) key) (. (TOK_TABLE_OR_COL b) key)))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)))) t)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF)))) + +STAGE DEPENDENCIES: + Stage-1 is a root stage + Stage-0 is a root stage + +STAGE PLANS: + Stage: Stage-1 + Map Reduce + Alias -> Map Operator Tree: + t:a:src + TableScan + alias: src + Select Operator + expressions: + expr: key + type: string + outputColumnNames: _col0 + Reduce Output Operator + key expressions: + expr: _col0 + type: string + sort order: + + Map-reduce partition columns: + expr: _col0 + type: string + tag: 0 + t:b:src1 + TableScan + alias: src1 + Select Operator + expressions: + expr: key + type: string + expr: value + type: string + outputColumnNames: _col0, _col1 + Reduce Output Operator + key expressions: + expr: _col0 + type: string + sort order: + + Map-reduce partition columns: + expr: _col0 + type: string + tag: 1 + value expressions: + expr: _col0 + type: string + expr: _col1 + type: string + Reduce Operator Tree: + Join Operator + condition map: + Inner Join 0 to 1 + condition expressions: + 0 + 1 {VALUE._col0} {VALUE._col1} + handleSkewJoin: false + outputColumnNames: _col2, _col3 + Select Operator + expressions: + expr: _col2 + type: string + expr: _col3 + type: string + outputColumnNames: _col2, _col3 + Select Operator + expressions: + expr: _col2 + type: string + expr: _col3 + type: string + outputColumnNames: _col0, _col1 + File Output Operator + compressed: false + GlobalTableId: 0 + table: + input format: org.apache.hadoop.mapred.TextInputFormat + output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat + + Stage: Stage-0 + Fetch Operator + limit: -1 + +