-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29506: HiveRelDecorrelator fails to decorrelate plan with Values operator #6360
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
Open
kasakrisz
wants to merge
2
commits into
apache:master
Choose a base branch
from
kasakrisz:HIVE-29506-master-decorrelate-values
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+95
−13
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
22 changes: 22 additions & 0 deletions
22
ql/src/test/queries/clientpositive/empty_result_correlate2.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,22 @@ | ||
| set hive.support.concurrency=true; | ||
| set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager; | ||
|
|
||
| -- To create a HiveValues operator before decorrelation automatic query rewrite with | ||
| -- materialized views is used. | ||
| -- All tables must be transactional to trigger automatic query rewrite. | ||
| create table mv_source (any_col int) stored as orc TBLPROPERTIES ('transactional'='true'); | ||
| create table t1 (a int, b int) stored as orc TBLPROPERTIES ('transactional'='true'); | ||
| create table t2 (a int, b int) stored as orc TBLPROPERTIES ('transactional'='true'); | ||
|
|
||
| -- At least one materialized view must exist. | ||
| create materialized view any_mv as | ||
| select any_col from mv_source where any_col > 20; | ||
|
|
||
| -- Automatic query rewrite traverses the plan and recreates the HiveFilter using RelBuilder. | ||
| -- If the condition is always false, it replaces the filter with HiveValues. | ||
| explain cbo | ||
| select * from t1 where 1 = 2 | ||
| union | ||
| select * from t1 | ||
| where exists (select a from t2 where t1.a > 10) | ||
| ; | ||
73 changes: 73 additions & 0 deletions
73
ql/src/test/results/clientpositive/llap/empty_result_correlate2.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,73 @@ | ||
| PREHOOK: query: create table mv_source (any_col int) stored as orc TBLPROPERTIES ('transactional'='true') | ||
| PREHOOK: type: CREATETABLE | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@mv_source | ||
| POSTHOOK: query: create table mv_source (any_col int) stored as orc TBLPROPERTIES ('transactional'='true') | ||
| POSTHOOK: type: CREATETABLE | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@mv_source | ||
| PREHOOK: query: create table t1 (a int, b int) stored as orc TBLPROPERTIES ('transactional'='true') | ||
| PREHOOK: type: CREATETABLE | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@t1 | ||
| POSTHOOK: query: create table t1 (a int, b int) stored as orc TBLPROPERTIES ('transactional'='true') | ||
| POSTHOOK: type: CREATETABLE | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@t1 | ||
| PREHOOK: query: create table t2 (a int, b int) stored as orc TBLPROPERTIES ('transactional'='true') | ||
| PREHOOK: type: CREATETABLE | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@t2 | ||
| POSTHOOK: query: create table t2 (a int, b int) stored as orc TBLPROPERTIES ('transactional'='true') | ||
| POSTHOOK: type: CREATETABLE | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@t2 | ||
| PREHOOK: query: create materialized view any_mv as | ||
| select any_col from mv_source where any_col > 20 | ||
| PREHOOK: type: CREATE_MATERIALIZED_VIEW | ||
| PREHOOK: Input: default@mv_source | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@any_mv | ||
| POSTHOOK: query: create materialized view any_mv as | ||
| select any_col from mv_source where any_col > 20 | ||
| POSTHOOK: type: CREATE_MATERIALIZED_VIEW | ||
| POSTHOOK: Input: default@mv_source | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@any_mv | ||
| POSTHOOK: Lineage: any_mv.any_col SIMPLE [(mv_source)mv_source.FieldSchema(name:any_col, type:int, comment:null), ] | ||
| Warning: Shuffle Join MERGEJOIN[38][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 5' is a cross product | ||
| PREHOOK: query: explain cbo | ||
| select * from t1 where 1 = 2 | ||
| union | ||
| select * from t1 | ||
| where exists (select a from t2 where t1.a > 10) | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@t1 | ||
| PREHOOK: Input: default@t2 | ||
| #### A masked pattern was here #### | ||
| POSTHOOK: query: explain cbo | ||
| select * from t1 where 1 = 2 | ||
| union | ||
| select * from t1 | ||
| where exists (select a from t2 where t1.a > 10) | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@t1 | ||
| POSTHOOK: Input: default@t2 | ||
| #### A masked pattern was here #### | ||
| CBO PLAN: | ||
| HiveProject(a=[$0], b=[$1]) | ||
| HiveAggregate(group=[{0, 1}]) | ||
| HiveSemiJoin(condition=[=($3, $2)], joinType=[semi]) | ||
| HiveProject(a=[$0], b=[$1], $f6=[>($0, 10)]) | ||
| HiveFilter(condition=[IS NOT NULL($0)]) | ||
| HiveTableScan(table=[[default, t1]], table:alias=[t1]) | ||
| HiveProject($f6=[$1]) | ||
| HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available]) | ||
| HiveProject(DUMMY=[0]) | ||
| HiveTableScan(table=[[default, t2]], table:alias=[t2]) | ||
| HiveProject($f6=[$0]) | ||
| HiveAggregate(group=[{0}]) | ||
| HiveProject($f6=[CAST(IS NOT NULL($0)):BOOLEAN]) | ||
| HiveFilter(condition=[>($0, 10)]) | ||
| HiveTableScan(table=[[default, t1]], table:alias=[t1]) | ||
|
|
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.
not sure we should be adding new tests with ACID table format, would it work with iceberg as well?
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 bug should occur when decorrelating any plan with a Values node. How about adding a unit test in a new class HiveRelDecorrelatorTest instead?