forked from apache/hive
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HIVE-26722: HiveFilterSetOpTransposeRule incorrectly prunes UNION ALL…
… operands. (apache#3748). (Alessandro Solimando, reviewed by Ayush Saxena, Simhadri Govindappa)
- Loading branch information
1 parent
5cb1b10
commit 310cdd8
Showing
4 changed files
with
145 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
ql/src/test/queries/clientpositive/union_all_filter_transpose.q
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# needed to avoid the simplification of CAST(NULL) into NULL | ||
set hive.cbo.rule.exclusion.regex=ReduceExpressionsRule\(Project\); | ||
|
||
CREATE EXTERNAL TABLE t (a string, b string); | ||
|
||
INSERT INTO t VALUES ('1000', 'b1'); | ||
INSERT INTO t VALUES ('2000', 'b2'); | ||
|
||
SELECT * FROM ( | ||
SELECT | ||
a, | ||
b | ||
FROM t | ||
UNION ALL | ||
SELECT | ||
a, | ||
CAST(NULL AS string) | ||
FROM t) AS t2 | ||
WHERE a = 1000; | ||
|
||
EXPLAIN CBO | ||
SELECT * FROM ( | ||
SELECT | ||
a, | ||
b | ||
FROM t | ||
UNION ALL | ||
SELECT | ||
a, | ||
CAST(NULL AS string) | ||
FROM t) AS t2 | ||
WHERE a = 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
ql/src/test/results/clientpositive/llap/union_all_filter_transpose.q.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
PREHOOK: query: CREATE EXTERNAL TABLE t (a string, b string) | ||
PREHOOK: type: CREATETABLE | ||
PREHOOK: Output: database:default | ||
PREHOOK: Output: default@t | ||
POSTHOOK: query: CREATE EXTERNAL TABLE t (a string, b string) | ||
POSTHOOK: type: CREATETABLE | ||
POSTHOOK: Output: database:default | ||
POSTHOOK: Output: default@t | ||
PREHOOK: query: INSERT INTO t VALUES ('1000', 'b1') | ||
PREHOOK: type: QUERY | ||
PREHOOK: Input: _dummy_database@_dummy_table | ||
PREHOOK: Output: default@t | ||
POSTHOOK: query: INSERT INTO t VALUES ('1000', 'b1') | ||
POSTHOOK: type: QUERY | ||
POSTHOOK: Input: _dummy_database@_dummy_table | ||
POSTHOOK: Output: default@t | ||
POSTHOOK: Lineage: t.a SCRIPT [] | ||
POSTHOOK: Lineage: t.b SCRIPT [] | ||
PREHOOK: query: INSERT INTO t VALUES ('2000', 'b2') | ||
PREHOOK: type: QUERY | ||
PREHOOK: Input: _dummy_database@_dummy_table | ||
PREHOOK: Output: default@t | ||
POSTHOOK: query: INSERT INTO t VALUES ('2000', 'b2') | ||
POSTHOOK: type: QUERY | ||
POSTHOOK: Input: _dummy_database@_dummy_table | ||
POSTHOOK: Output: default@t | ||
POSTHOOK: Lineage: t.a SCRIPT [] | ||
POSTHOOK: Lineage: t.b SCRIPT [] | ||
PREHOOK: query: SELECT * FROM ( | ||
SELECT | ||
a, | ||
b | ||
FROM t | ||
UNION ALL | ||
SELECT | ||
a, | ||
CAST(NULL AS string) | ||
FROM t) AS t2 | ||
WHERE a = 1000 | ||
PREHOOK: type: QUERY | ||
PREHOOK: Input: default@t | ||
#### A masked pattern was here #### | ||
POSTHOOK: query: SELECT * FROM ( | ||
SELECT | ||
a, | ||
b | ||
FROM t | ||
UNION ALL | ||
SELECT | ||
a, | ||
CAST(NULL AS string) | ||
FROM t) AS t2 | ||
WHERE a = 1000 | ||
POSTHOOK: type: QUERY | ||
POSTHOOK: Input: default@t | ||
#### A masked pattern was here #### | ||
1000 b1 | ||
1000 NULL | ||
PREHOOK: query: EXPLAIN CBO | ||
SELECT * FROM ( | ||
SELECT | ||
a, | ||
b | ||
FROM t | ||
UNION ALL | ||
SELECT | ||
a, | ||
CAST(NULL AS string) | ||
FROM t) AS t2 | ||
WHERE a = 1000 | ||
PREHOOK: type: QUERY | ||
PREHOOK: Input: default@t | ||
#### A masked pattern was here #### | ||
POSTHOOK: query: EXPLAIN CBO | ||
SELECT * FROM ( | ||
SELECT | ||
a, | ||
b | ||
FROM t | ||
UNION ALL | ||
SELECT | ||
a, | ||
CAST(NULL AS string) | ||
FROM t) AS t2 | ||
WHERE a = 1000 | ||
POSTHOOK: type: QUERY | ||
POSTHOOK: Input: default@t | ||
#### A masked pattern was here #### | ||
Excluded rules: ReduceExpressionsRule\(Project\) | ||
|
||
CBO PLAN: | ||
HiveUnion(all=[true]) | ||
HiveProject(a=[$0], b=[$1]) | ||
HiveFilter(condition=[=(CAST($0):DOUBLE, 1000)]) | ||
HiveTableScan(table=[[default, t]], table:alias=[t]) | ||
HiveProject(a=[$0], _o__c1=[null:VARCHAR(2147483647) CHARACTER SET "UTF-16LE"]) | ||
HiveFilter(condition=[=(CAST($0):DOUBLE, 1000)]) | ||
HiveTableScan(table=[[default, t]], table:alias=[t]) | ||
|