diff --git itests/src/test/resources/testconfiguration.properties itests/src/test/resources/testconfiguration.properties index aa3d72d..219d928 100644 --- itests/src/test/resources/testconfiguration.properties +++ itests/src/test/resources/testconfiguration.properties @@ -566,6 +566,7 @@ minillaplocal.query.files=acid_globallimit.q,\ special_character_in_tabnames_1.q,\ stats_based_fetch_decision.q,\ subquery_notin.q,\ + subquery_null_agg.q,\ table_access_keys_stats.q,\ tez_bmj_schema_evolution.q,\ tez_dml.q,\ diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java index ace3eaf..9752ce0 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java @@ -70,10 +70,8 @@ import org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPOr; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFWhen; import org.apache.hadoop.hive.serde.serdeConstants; -import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category; -import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; import org.apache.hadoop.hive.serde2.typeinfo.CharTypeInfo; import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo; @@ -666,14 +664,6 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, } private static ExprNodeDesc toExprNodeDesc(ColumnInfo colInfo) { - ObjectInspector inspector = colInfo.getObjectInspector(); - if (inspector instanceof ConstantObjectInspector && - inspector instanceof PrimitiveObjectInspector) { - PrimitiveObjectInspector poi = (PrimitiveObjectInspector) inspector; - Object constant = ((ConstantObjectInspector) inspector).getWritableConstantValue(); - return new ExprNodeConstantDesc(colInfo.getType(), poi.getPrimitiveJavaObject(constant)); - } - // non-constant or non-primitive constants ExprNodeColumnDesc column = new ExprNodeColumnDesc(colInfo); column.setSkewedCol(colInfo.isSkewedCol()); return column; diff --git ql/src/test/queries/clientpositive/subquery_null_agg.q ql/src/test/queries/clientpositive/subquery_null_agg.q new file mode 100644 index 0000000..ca0d5c7 --- /dev/null +++ ql/src/test/queries/clientpositive/subquery_null_agg.q @@ -0,0 +1,22 @@ +set hive.strict.checks.cartesian.product=false; + +CREATE TABLE table_7 (int_col INT); + +explain +SELECT +(t1.int_col) * (t1.int_col) AS int_col +FROM ( +SELECT +MIN(NULL) OVER () AS int_col +FROM table_7 +) t1 +WHERE +(False) NOT IN (SELECT +False AS boolean_col +FROM ( +SELECT +MIN(NULL) OVER () AS int_col +FROM table_7 +) tt1 +WHERE +(t1.int_col) = (tt1.int_col)); diff --git ql/src/test/results/clientpositive/llap/subquery_null_agg.q.out ql/src/test/results/clientpositive/llap/subquery_null_agg.q.out new file mode 100644 index 0000000..d60f364 --- /dev/null +++ ql/src/test/results/clientpositive/llap/subquery_null_agg.q.out @@ -0,0 +1,265 @@ +PREHOOK: query: CREATE TABLE table_7 (int_col INT) +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +PREHOOK: Output: default@table_7 +POSTHOOK: query: CREATE TABLE table_7 (int_col INT) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@table_7 +Warning: Shuffle Join MERGEJOIN[38][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 3' is a cross product +PREHOOK: query: explain +SELECT +(t1.int_col) * (t1.int_col) AS int_col +FROM ( +SELECT +MIN(NULL) OVER () AS int_col +FROM table_7 +) t1 +WHERE +(False) NOT IN (SELECT +False AS boolean_col +FROM ( +SELECT +MIN(NULL) OVER () AS int_col +FROM table_7 +) tt1 +WHERE +(t1.int_col) = (tt1.int_col)) +PREHOOK: type: QUERY +POSTHOOK: query: explain +SELECT +(t1.int_col) * (t1.int_col) AS int_col +FROM ( +SELECT +MIN(NULL) OVER () AS int_col +FROM table_7 +) t1 +WHERE +(False) NOT IN (SELECT +False AS boolean_col +FROM ( +SELECT +MIN(NULL) OVER () AS int_col +FROM table_7 +) tt1 +WHERE +(t1.int_col) = (tt1.int_col)) +POSTHOOK: type: QUERY +STAGE DEPENDENCIES: + Stage-1 is a root stage + Stage-0 depends on stages: Stage-1 + +STAGE PLANS: + Stage: Stage-1 + Tez +#### A masked pattern was here #### + Edges: + Reducer 2 <- Map 1 (SIMPLE_EDGE) + Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE) + Reducer 4 <- Reducer 3 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE) + Reducer 6 <- Map 5 (SIMPLE_EDGE) + Reducer 7 <- Reducer 6 (SIMPLE_EDGE) + Reducer 9 <- Map 8 (SIMPLE_EDGE) +#### A masked pattern was here #### + Vertices: + Map 1 + Map Operator Tree: + TableScan + alias: table_7 + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Reduce Output Operator + key expressions: 0 (type: int) + sort order: + + Map-reduce partition columns: 0 (type: int) + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Execution mode: llap + LLAP IO: no inputs + Map 5 + Map Operator Tree: + TableScan + alias: table_7 + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Reduce Output Operator + key expressions: 0 (type: int) + sort order: + + Map-reduce partition columns: 0 (type: int) + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Execution mode: llap + LLAP IO: no inputs + Map 8 + Map Operator Tree: + TableScan + alias: table_7 + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Reduce Output Operator + key expressions: 0 (type: int) + sort order: + + Map-reduce partition columns: 0 (type: int) + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Execution mode: llap + LLAP IO: no inputs + Reducer 2 + Execution mode: llap + Reduce Operator Tree: + PTF Operator + Function definitions: + Input definition + input alias: ptf_0 + output shape: + type: WINDOWING + Windowing table definition + input alias: ptf_1 + name: windowingtablefunction + order by: 0 ASC NULLS FIRST + partition by: 0 + raw input shape: + window functions: + window function definition + alias: min_window_0 + arguments: null + name: min + window function: GenericUDAFMinEvaluator + window frame: PRECEDING(MAX)~FOLLOWING(MAX) + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Select Operator + expressions: min_window_0 (type: void) + outputColumnNames: _col0 + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Reduce Output Operator + sort order: + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + value expressions: _col0 (type: void) + Reducer 3 + Execution mode: llap + Reduce Operator Tree: + Merge Join Operator + condition map: + Inner Join 0 to 1 + keys: + 0 + 1 + outputColumnNames: _col0 + Statistics: Num rows: 1 Data size: 9 Basic stats: COMPLETE Column stats: NONE + Reduce Output Operator + key expressions: _col0 (type: void) + sort order: + + Map-reduce partition columns: _col0 (type: void) + Statistics: Num rows: 1 Data size: 9 Basic stats: COMPLETE Column stats: NONE + Reducer 4 + Execution mode: llap + Reduce Operator Tree: + Merge Join Operator + condition map: + Left Outer Join0 to 1 + keys: + 0 _col0 (type: void) + 1 _col1 (type: void) + outputColumnNames: _col0, _col2 + Statistics: Num rows: 1 Data size: 9 Basic stats: COMPLETE Column stats: NONE + Filter Operator + predicate: _col2 is null (type: boolean) + Statistics: Num rows: 1 Data size: 9 Basic stats: COMPLETE Column stats: NONE + Select Operator + expressions: (UDFToDouble(_col0) * UDFToDouble(_col0)) (type: double) + outputColumnNames: _col0 + Statistics: Num rows: 1 Data size: 9 Basic stats: COMPLETE Column stats: NONE + File Output Operator + compressed: false + Statistics: Num rows: 1 Data size: 9 Basic stats: COMPLETE Column stats: NONE + table: + input format: org.apache.hadoop.mapred.SequenceFileInputFormat + output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat + serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe + Reducer 6 + Execution mode: llap + Reduce Operator Tree: + PTF Operator + Function definitions: + Input definition + input alias: ptf_0 + output shape: + type: WINDOWING + Windowing table definition + input alias: ptf_1 + name: windowingtablefunction + order by: 0 ASC NULLS FIRST + partition by: 0 + raw input shape: + window functions: + window function definition + alias: min_window_0 + arguments: null + name: min + window function: GenericUDAFMinEvaluator + window frame: PRECEDING(MAX)~FOLLOWING(MAX) + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Filter Operator + predicate: min_window_0 is null (type: boolean) + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Select Operator + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Group By Operator + aggregations: count() + mode: hash + outputColumnNames: _col0 + Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE + Reduce Output Operator + sort order: + Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE + value expressions: _col0 (type: bigint) + Reducer 7 + Execution mode: llap + Reduce Operator Tree: + Group By Operator + aggregations: count(VALUE._col0) + mode: mergepartial + outputColumnNames: _col0 + Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE + Filter Operator + predicate: (_col0 = 0) (type: boolean) + Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE + Select Operator + Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE + Reduce Output Operator + sort order: + Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE + Reducer 9 + Execution mode: llap + Reduce Operator Tree: + PTF Operator + Function definitions: + Input definition + input alias: ptf_0 + output shape: + type: WINDOWING + Windowing table definition + input alias: ptf_1 + name: windowingtablefunction + order by: 0 ASC NULLS FIRST + partition by: 0 + raw input shape: + window functions: + window function definition + alias: min_window_0 + arguments: null + name: min + window function: GenericUDAFMinEvaluator + window frame: PRECEDING(MAX)~FOLLOWING(MAX) + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Select Operator + expressions: false (type: boolean), min_window_0 (type: void) + outputColumnNames: _col0, _col1 + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + Reduce Output Operator + key expressions: _col1 (type: void) + sort order: + + Map-reduce partition columns: _col1 (type: void) + Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE + value expressions: _col0 (type: boolean) + + Stage: Stage-0 + Fetch Operator + limit: -1 + Processor Tree: + ListSink +