-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29496: Subsequent transactional materialized view rebuild fails when source tables are iceberg tables #6434
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
kasakrisz
merged 5 commits into
apache:master
from
kasakrisz:HIVE-29496-master-acid-mv-lock
Apr 30, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8e48682
HIVE-29496: Subsequent transactional materialized view rebuild fails …
kasakrisz 1bdab35
revert lock acquisition move
kasakrisz 3634e3c
trigger txn id generation
kasakrisz d8788ce
open txn by txnManager instead of getValidTxnList()
kasakrisz 6cc759f
check whether txn is open
kasakrisz 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
28 changes: 28 additions & 0 deletions
28
iceberg/iceberg-handler/src/test/queries/positive/mv_iceberg_orc9.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,28 @@ | ||
| -- Test subsequent rebuild of transactional MV when source table is Iceberg. | ||
|
|
||
| -- SORT_QUERY_RESULTS | ||
| set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager; | ||
| set hive.support.concurrency=true; | ||
|
|
||
| create table ice_basetable (a int, b string) stored by iceberg; | ||
| insert into ice_basetable values (1, 'alfred'),(2, 'bob'),(2, 'bonnie'),(3, 'calvin'),(3, 'charlie'); | ||
|
|
||
| create materialized view mv_acid STORED AS ORC TBLPROPERTIES ('transactional'='true') as | ||
| select b, a from ice_basetable; | ||
|
|
||
| create materialized view mv_insert_only STORED AS ORC TBLPROPERTIES ('transactional'='true', 'transactional_properties'='insert_only') as | ||
| select b, a from ice_basetable; | ||
|
|
||
| select * from mv_acid; | ||
| select * from mv_insert_only; | ||
|
|
||
| insert into ice_basetable values (5, 'amia'); | ||
| alter materialized view mv_acid rebuild; | ||
| alter materialized view mv_insert_only rebuild; | ||
|
|
||
| insert into ice_basetable values (4, 'mania'); | ||
| alter materialized view mv_acid rebuild; | ||
| alter materialized view mv_insert_only rebuild; | ||
|
|
||
| select * from mv_acid; | ||
| select * from mv_insert_only; | ||
156 changes: 156 additions & 0 deletions
156
iceberg/iceberg-handler/src/test/results/positive/mv_iceberg_orc9.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,156 @@ | ||
| PREHOOK: query: create table ice_basetable (a int, b string) stored by iceberg | ||
| PREHOOK: type: CREATETABLE | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@ice_basetable | ||
| POSTHOOK: query: create table ice_basetable (a int, b string) stored by iceberg | ||
| POSTHOOK: type: CREATETABLE | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@ice_basetable | ||
| PREHOOK: query: insert into ice_basetable values (1, 'alfred'),(2, 'bob'),(2, 'bonnie'),(3, 'calvin'),(3, 'charlie') | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: _dummy_database@_dummy_table | ||
| PREHOOK: Output: default@ice_basetable | ||
| POSTHOOK: query: insert into ice_basetable values (1, 'alfred'),(2, 'bob'),(2, 'bonnie'),(3, 'calvin'),(3, 'charlie') | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: _dummy_database@_dummy_table | ||
| POSTHOOK: Output: default@ice_basetable | ||
| PREHOOK: query: create materialized view mv_acid STORED AS ORC TBLPROPERTIES ('transactional'='true') as | ||
| select b, a from ice_basetable | ||
| PREHOOK: type: CREATE_MATERIALIZED_VIEW | ||
| PREHOOK: Input: default@ice_basetable | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@mv_acid | ||
| POSTHOOK: query: create materialized view mv_acid STORED AS ORC TBLPROPERTIES ('transactional'='true') as | ||
| select b, a from ice_basetable | ||
| POSTHOOK: type: CREATE_MATERIALIZED_VIEW | ||
| POSTHOOK: Input: default@ice_basetable | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@mv_acid | ||
| POSTHOOK: Lineage: mv_acid.a SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:a, type:int, comment:null), ] | ||
| POSTHOOK: Lineage: mv_acid.b SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:b, type:string, comment:null), ] | ||
| PREHOOK: query: create materialized view mv_insert_only STORED AS ORC TBLPROPERTIES ('transactional'='true', 'transactional_properties'='insert_only') as | ||
| select b, a from ice_basetable | ||
| PREHOOK: type: CREATE_MATERIALIZED_VIEW | ||
| PREHOOK: Input: default@ice_basetable | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@mv_insert_only | ||
| POSTHOOK: query: create materialized view mv_insert_only STORED AS ORC TBLPROPERTIES ('transactional'='true', 'transactional_properties'='insert_only') as | ||
| select b, a from ice_basetable | ||
| POSTHOOK: type: CREATE_MATERIALIZED_VIEW | ||
| POSTHOOK: Input: default@ice_basetable | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@mv_insert_only | ||
| POSTHOOK: Lineage: mv_insert_only.a SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:a, type:int, comment:null), ] | ||
| POSTHOOK: Lineage: mv_insert_only.b SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:b, type:string, comment:null), ] | ||
| PREHOOK: query: select * from mv_acid | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@mv_acid | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: select * from mv_acid | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@mv_acid | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| alfred 1 | ||
| bob 2 | ||
| bonnie 2 | ||
| calvin 3 | ||
| charlie 3 | ||
| PREHOOK: query: select * from mv_insert_only | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@mv_insert_only | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: select * from mv_insert_only | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@mv_insert_only | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| alfred 1 | ||
| bob 2 | ||
| bonnie 2 | ||
| calvin 3 | ||
| charlie 3 | ||
| PREHOOK: query: insert into ice_basetable values (5, 'amia') | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: _dummy_database@_dummy_table | ||
| PREHOOK: Output: default@ice_basetable | ||
| POSTHOOK: query: insert into ice_basetable values (5, 'amia') | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: _dummy_database@_dummy_table | ||
| POSTHOOK: Output: default@ice_basetable | ||
| PREHOOK: query: alter materialized view mv_acid rebuild | ||
| PREHOOK: type: ALTER_MATERIALIZED_VIEW_REBUILD | ||
| PREHOOK: Input: default@ice_basetable | ||
| PREHOOK: Output: default@mv_acid | ||
| POSTHOOK: query: alter materialized view mv_acid rebuild | ||
| POSTHOOK: type: ALTER_MATERIALIZED_VIEW_REBUILD | ||
| POSTHOOK: Input: default@ice_basetable | ||
| POSTHOOK: Output: default@mv_acid | ||
| POSTHOOK: Lineage: mv_acid.a SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:a, type:int, comment:null), ] | ||
| POSTHOOK: Lineage: mv_acid.b SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:b, type:string, comment:null), ] | ||
| PREHOOK: query: alter materialized view mv_insert_only rebuild | ||
| PREHOOK: type: ALTER_MATERIALIZED_VIEW_REBUILD | ||
| PREHOOK: Input: default@ice_basetable | ||
| PREHOOK: Output: default@mv_insert_only | ||
| POSTHOOK: query: alter materialized view mv_insert_only rebuild | ||
| POSTHOOK: type: ALTER_MATERIALIZED_VIEW_REBUILD | ||
| POSTHOOK: Input: default@ice_basetable | ||
| POSTHOOK: Output: default@mv_insert_only | ||
| POSTHOOK: Lineage: mv_insert_only.a SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:a, type:int, comment:null), ] | ||
| POSTHOOK: Lineage: mv_insert_only.b SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:b, type:string, comment:null), ] | ||
| PREHOOK: query: insert into ice_basetable values (4, 'mania') | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: _dummy_database@_dummy_table | ||
| PREHOOK: Output: default@ice_basetable | ||
| POSTHOOK: query: insert into ice_basetable values (4, 'mania') | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: _dummy_database@_dummy_table | ||
| POSTHOOK: Output: default@ice_basetable | ||
| PREHOOK: query: alter materialized view mv_acid rebuild | ||
| PREHOOK: type: ALTER_MATERIALIZED_VIEW_REBUILD | ||
| PREHOOK: Input: default@ice_basetable | ||
| PREHOOK: Output: default@mv_acid | ||
| POSTHOOK: query: alter materialized view mv_acid rebuild | ||
| POSTHOOK: type: ALTER_MATERIALIZED_VIEW_REBUILD | ||
| POSTHOOK: Input: default@ice_basetable | ||
| POSTHOOK: Output: default@mv_acid | ||
| POSTHOOK: Lineage: mv_acid.a SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:a, type:int, comment:null), ] | ||
| POSTHOOK: Lineage: mv_acid.b SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:b, type:string, comment:null), ] | ||
| PREHOOK: query: alter materialized view mv_insert_only rebuild | ||
| PREHOOK: type: ALTER_MATERIALIZED_VIEW_REBUILD | ||
| PREHOOK: Input: default@ice_basetable | ||
| PREHOOK: Output: default@mv_insert_only | ||
| POSTHOOK: query: alter materialized view mv_insert_only rebuild | ||
| POSTHOOK: type: ALTER_MATERIALIZED_VIEW_REBUILD | ||
| POSTHOOK: Input: default@ice_basetable | ||
| POSTHOOK: Output: default@mv_insert_only | ||
| POSTHOOK: Lineage: mv_insert_only.a SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:a, type:int, comment:null), ] | ||
| POSTHOOK: Lineage: mv_insert_only.b SIMPLE [(ice_basetable)ice_basetable.FieldSchema(name:b, type:string, comment:null), ] | ||
| PREHOOK: query: select * from mv_acid | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@mv_acid | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: select * from mv_acid | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@mv_acid | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| alfred 1 | ||
| amia 5 | ||
| bob 2 | ||
| bonnie 2 | ||
| calvin 3 | ||
| charlie 3 | ||
| mania 4 | ||
| PREHOOK: query: select * from mv_insert_only | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@mv_insert_only | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: select * from mv_insert_only | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@mv_insert_only | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| alfred 1 | ||
| amia 5 | ||
| bob 2 | ||
| bonnie 2 | ||
| calvin 3 | ||
| charlie 3 | ||
| mania 4 |
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.
Thinking out loud: shouldn't we add a test case when the MV itself stored by iceberg?
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.
there are already tests like
https://github.com/apache/hive/blob/master/iceberg/iceberg-handler/src/test/queries/positive/mv_iceberg_orc2.q