-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-28938: Error in LATERAL VIEW with non native tables due to prese… #5798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
05b1e4c
HIVE-28938: Error in LATERAL VIEW with non native tables due to prese…
soumyakanti3578 0fd007c
Added isNative() method so that we can stop using double negation wit…
soumyakanti3578 3f99aa0
Fix test failures
soumyakanti3578 37d8ab1
revert some changes
soumyakanti3578 cd5abdd
small refactor
soumyakanti3578 b7465da
Address nits, add a test for explain formatted
soumyakanti3578 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
3 changes: 3 additions & 0 deletions
3
iceberg/iceberg-handler/src/test/queries/positive/iceberg_explain_formatted.q
This file contains hidden or 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,3 @@ | ||
-- A simple explain formatted test for an iceberg table to check virtual columns in the JSON output. | ||
create external table test (a int, b int) stored by iceberg; | ||
explain formatted select * from test; |
6 changes: 6 additions & 0 deletions
6
iceberg/iceberg-handler/src/test/queries/positive/iceberg_multiple_lateral_views.q
This file contains hidden or 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,6 @@ | ||
create external table test(id int, arr array<string>) stored by iceberg; | ||
insert into test values (1, array("a", "b")), (2, array("c", "d")), (3, array("e", "f")); | ||
|
||
select * from test | ||
lateral view explode(arr) tbl1 as name | ||
lateral view explode(arr) tbl2 as name1; |
17 changes: 17 additions & 0 deletions
17
iceberg/iceberg-handler/src/test/results/positive/iceberg_explain_formatted.q.out
This file contains hidden or 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,17 @@ | ||
PREHOOK: query: create external table test (a int, b int) stored by iceberg | ||
PREHOOK: type: CREATETABLE | ||
PREHOOK: Output: database:default | ||
PREHOOK: Output: default@test | ||
POSTHOOK: query: create external table test (a int, b int) stored by iceberg | ||
POSTHOOK: type: CREATETABLE | ||
POSTHOOK: Output: database:default | ||
POSTHOOK: Output: default@test | ||
PREHOOK: query: explain formatted select * from test | ||
PREHOOK: type: QUERY | ||
PREHOOK: Input: default@test | ||
PREHOOK: Output: hdfs://### HDFS PATH ### | ||
POSTHOOK: query: explain formatted select * from test | ||
POSTHOOK: type: QUERY | ||
POSTHOOK: Input: default@test | ||
POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
{"CBOPlan":"{\n \"rels\": [\n {\n \"id\": \"0\",\n \"relOp\": \"org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan\",\n \"table\": [\n \"default\",\n \"test\"\n ],\n \"table:alias\": \"test\",\n \"inputs\": [],\n \"rowCount\": 1.0,\n \"avgRowSize\": 8.0,\n \"rowType\": {\n \"fields\": [\n {\n \"type\": \"INTEGER\",\n \"nullable\": true,\n \"name\": \"a\"\n },\n {\n \"type\": \"INTEGER\",\n \"nullable\": true,\n \"name\": \"b\"\n },\n {\n \"type\": \"INTEGER\",\n \"nullable\": true,\n \"name\": \"PARTITION__SPEC__ID\"\n },\n {\n \"type\": \"BIGINT\",\n \"nullable\": true,\n \"name\": \"PARTITION__HASH\"\n },\n {\n \"type\": \"VARCHAR\",\n \"nullable\": true,\n \"precision\": 2147483647,\n \"name\": \"FILE__PATH\"\n },\n {\n \"type\": \"BIGINT\",\n \"nullable\": true,\n \"name\": \"ROW__POSITION\"\n },\n {\n \"type\": \"VARCHAR\",\n \"nullable\": true,\n \"precision\": 2147483647,\n \"name\": \"PARTITION__PROJECTION\"\n },\n {\n \"type\": \"BIGINT\",\n \"nullable\": true,\n \"name\": \"SNAPSHOT__ID\"\n }\n ],\n \"nullable\": false\n },\n \"colStats\": [\n {\n \"name\": \"a\",\n \"ndv\": 1,\n \"minValue\": -9223372036854775808,\n \"maxValue\": 9223372036854775807\n },\n {\n \"name\": \"b\",\n \"ndv\": 1,\n \"minValue\": -9223372036854775808,\n \"maxValue\": 9223372036854775807\n }\n ]\n },\n {\n \"id\": \"1\",\n \"relOp\": \"org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveProject\",\n \"fields\": [\n \"a\",\n \"b\"\n ],\n \"exprs\": [\n {\n \"input\": 0,\n \"name\": \"$0\"\n },\n {\n \"input\": 1,\n \"name\": \"$1\"\n }\n ],\n \"rowCount\": 1.0\n }\n ]\n}","optimizedSQL":"SELECT `a`, `b`\nFROM `default`.`test`","cboInfo":"Plan optimized by CBO.","STAGE DEPENDENCIES":{"Stage-0":{"ROOT STAGE":"TRUE"}},"STAGE PLANS":{"Stage-0":{"Fetch Operator":{"limit:":"-1","Processor Tree:":{"TableScan":{"alias:":"test","columns:":["a","b"],"database:":"default","table:":"test","isTempTable:":"false","OperatorId:":"TS_0","children":{"Select Operator":{"expressions:":"a (type: int), b (type: int)","columnExprMap:":{"_col0":"a","_col1":"b"},"outputColumnNames:":["_col0","_col1"],"OperatorId:":"SEL_1","children":{"ListSink":{"OperatorId:":"LIST_SINK_3"}}}}}}}}}} |
40 changes: 40 additions & 0 deletions
40
iceberg/iceberg-handler/src/test/results/positive/iceberg_multiple_lateral_views.q.out
This file contains hidden or 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,40 @@ | ||
PREHOOK: query: create external table test(id int, arr array<string>) stored by iceberg | ||
PREHOOK: type: CREATETABLE | ||
PREHOOK: Output: database:default | ||
PREHOOK: Output: default@test | ||
POSTHOOK: query: create external table test(id int, arr array<string>) stored by iceberg | ||
POSTHOOK: type: CREATETABLE | ||
POSTHOOK: Output: database:default | ||
POSTHOOK: Output: default@test | ||
PREHOOK: query: insert into test values (1, array("a", "b")), (2, array("c", "d")), (3, array("e", "f")) | ||
PREHOOK: type: QUERY | ||
PREHOOK: Input: _dummy_database@_dummy_table | ||
PREHOOK: Output: default@test | ||
POSTHOOK: query: insert into test values (1, array("a", "b")), (2, array("c", "d")), (3, array("e", "f")) | ||
POSTHOOK: type: QUERY | ||
POSTHOOK: Input: _dummy_database@_dummy_table | ||
POSTHOOK: Output: default@test | ||
PREHOOK: query: select * from test | ||
lateral view explode(arr) tbl1 as name | ||
lateral view explode(arr) tbl2 as name1 | ||
PREHOOK: type: QUERY | ||
PREHOOK: Input: default@test | ||
PREHOOK: Output: hdfs://### HDFS PATH ### | ||
POSTHOOK: query: select * from test | ||
lateral view explode(arr) tbl1 as name | ||
lateral view explode(arr) tbl2 as name1 | ||
POSTHOOK: type: QUERY | ||
POSTHOOK: Input: default@test | ||
POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
1 ["a","b"] a a | ||
1 ["a","b"] a b | ||
1 ["a","b"] b a | ||
1 ["a","b"] b b | ||
2 ["c","d"] c c | ||
2 ["c","d"] c d | ||
2 ["c","d"] d c | ||
2 ["c","d"] d d | ||
3 ["e","f"] e e | ||
3 ["e","f"] e f | ||
3 ["e","f"] f e | ||
3 ["e","f"] f f |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious why HBase (and Kudu in another file) column type changed from int to double. The stats above shows 4 bytes which indicates integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this PR, we don't see any virtual columns for the HBase table, whereas earlier virtual columns for native tables were getting wrongly added to the HBase tables. This affects the plan in the CBO, especially in RelFieldTrimmer.
With the PR, the plan after RelFieldTrimmer is:
whereas earlier the plan was:
We see that the
CAST
s are getting pushed down from theJoin
now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new plan with the pushed down cast 'key' to double on both sides of the join looks good to me, although I don't know why the extraneous virtual columns in the past would have prevented the push down since the cast is on a user column. But that's a separate topic.