-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29546: Iceberg: [V3] Support of ROW LINEAGE in COMPACTION #6407
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
kokila-19
wants to merge
2
commits into
apache:master
Choose a base branch
from
kokila-19:row_lineage_comp
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.
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
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
141 changes: 141 additions & 0 deletions
141
iceberg/iceberg-handler/src/test/queries/positive/iceberg_row_lineage_compactions.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,141 @@ | ||
| -- SORT_QUERY_RESULTS | ||
|
|
||
| --! qt:replace:/(MAJOR\s+succeeded\s+)[a-zA-Z0-9\-\.\s+]+(\s+manual)/$1#Masked#$2/ | ||
| --! qt:replace:/(MAJOR\s+refused\s+)[a-zA-Z0-9\-\.\s+]+(\s+manual)/$1#Masked#$2/ | ||
| --! qt:replace:/(MINOR\s+succeeded\s+)[a-zA-Z0-9\-\.\s+]+(\s+manual)/$1#Masked#$2/ | ||
| --! qt:replace:/(MINOR\s+refused\s+)[a-zA-Z0-9\-\.\s+]+(\s+manual)/$1#Masked#$2/ | ||
| -- Mask compaction id as they will be allocated in parallel threads | ||
| --! qt:replace:/^(\d+)(\t.*\tmanual\ticeberg\t)/#Masked#$2/ | ||
|
|
||
| set hive.llap.io.enabled=true; | ||
| set hive.vectorized.execution.enabled=true; | ||
|
|
||
| create database if not exists ice_comp_all with dbproperties('hive.compactor.worker.pool'='iceberg'); | ||
| use ice_comp_all; | ||
|
|
||
| -- Partitioned table with minor and major compaction | ||
| create table part_tbl( | ||
| id int, | ||
| data string | ||
| ) | ||
| partitioned by (dept_id int) | ||
| stored by iceberg stored as parquet | ||
| tblproperties ( | ||
| 'format-version'='3', | ||
| 'hive.compactor.worker.pool'='iceberg', | ||
| -- Use target.size only to make Parquet data files (~996 bytes) count as fragments. | ||
| -- Default fragment ratio is 8, so fragment_size = target_size / 8. | ||
| -- Pick target_size > 996 * 8 (7968) so files are treated as fragment files and minor compaction is eligible. | ||
| 'compactor.threshold.target.size'='8000', | ||
| 'compactor.threshold.min.input.files'='2', | ||
| 'compactor.threshold.delete.file.ratio'='0.0' | ||
| ); | ||
|
|
||
| insert into part_tbl values (1,'p1', 10); | ||
| insert into part_tbl values (2,'p2', 10); | ||
| insert into part_tbl values (3,'p3', 20); | ||
| insert into part_tbl values (4,'p4', 20); | ||
|
|
||
| SELECT *, ROW__LINEAGE__ID, LAST__UPDATED__SEQUENCE__NUMBER | ||
| FROM part_tbl | ||
| ORDER BY ROW__LINEAGE__ID; | ||
|
|
||
| alter table part_tbl compact 'minor' and wait pool 'iceberg'; | ||
|
|
||
| SELECT *, ROW__LINEAGE__ID, LAST__UPDATED__SEQUENCE__NUMBER | ||
| FROM part_tbl | ||
| ORDER BY ROW__LINEAGE__ID; | ||
|
|
||
| show compactions; | ||
|
|
||
| -- For MAJOR eligibility, avoid treating files as "fragments" by lowering target.size | ||
| alter table part_tbl set tblproperties ('compactor.threshold.target.size'='1500'); | ||
|
|
||
| merge into part_tbl t | ||
| using (select 1 as id, 'p1_upd' as data, 10 as dept_id) s | ||
| on t.dept_id = s.dept_id and t.id = s.id | ||
| when matched then update set data = s.data; | ||
|
|
||
| SELECT *, ROW__LINEAGE__ID, LAST__UPDATED__SEQUENCE__NUMBER | ||
| FROM part_tbl | ||
| ORDER BY ROW__LINEAGE__ID; | ||
|
|
||
| alter table part_tbl compact 'major' and wait pool 'iceberg'; | ||
|
|
||
| SELECT *, ROW__LINEAGE__ID, LAST__UPDATED__SEQUENCE__NUMBER | ||
| FROM part_tbl | ||
| ORDER BY ROW__LINEAGE__ID; | ||
|
|
||
| show compactions; | ||
|
|
||
| -- Partition evolution | ||
| alter table part_tbl set tblproperties ('compactor.threshold.target.size'='8000'); | ||
|
|
||
| alter table part_tbl set partition spec(dept_id, id); | ||
|
|
||
| insert into part_tbl values (5,'p5', 10); | ||
| insert into part_tbl values (6,'p6', 20); | ||
|
|
||
| SELECT *, ROW__LINEAGE__ID, LAST__UPDATED__SEQUENCE__NUMBER | ||
| FROM part_tbl | ||
| ORDER BY ROW__LINEAGE__ID; | ||
|
|
||
| alter table part_tbl compact 'minor' and wait pool 'iceberg'; | ||
|
|
||
| SELECT *, ROW__LINEAGE__ID, LAST__UPDATED__SEQUENCE__NUMBER | ||
| FROM part_tbl | ||
| ORDER BY ROW__LINEAGE__ID; | ||
|
|
||
| show compactions; | ||
|
|
||
| -- Unpartitioned table with minor and major compaction | ||
| create table unpart_tbl( | ||
| id int, | ||
| data string | ||
| ) | ||
| stored by iceberg stored as parquet | ||
| tblproperties ( | ||
| 'format-version'='3', | ||
| 'hive.compactor.worker.pool'='iceberg', | ||
| -- Use target.size only to make Parquet data files (~996 bytes) count as fragments (default ratio 8). | ||
| 'compactor.threshold.target.size'='8000', | ||
| 'compactor.threshold.min.input.files'='2', | ||
| 'compactor.threshold.delete.file.ratio'='0.0' | ||
| ); | ||
|
|
||
| insert into unpart_tbl values (1,'a'); | ||
| insert into unpart_tbl values (2,'b'); | ||
| insert into unpart_tbl values (3,'c'); | ||
| insert into unpart_tbl values (4,'d'); | ||
|
|
||
| SELECT *, ROW__LINEAGE__ID, LAST__UPDATED__SEQUENCE__NUMBER | ||
| FROM unpart_tbl | ||
| ORDER BY ROW__LINEAGE__ID; | ||
|
|
||
| alter table unpart_tbl compact 'minor' and wait pool 'iceberg'; | ||
|
|
||
| SELECT *, ROW__LINEAGE__ID, LAST__UPDATED__SEQUENCE__NUMBER | ||
| FROM unpart_tbl | ||
| ORDER BY ROW__LINEAGE__ID; | ||
|
|
||
| show compactions; | ||
|
|
||
| -- For MAJOR eligibility, avoid treating files as "fragments" by lowering target.size, then create deletes via MERGE. | ||
| alter table unpart_tbl set tblproperties ('compactor.threshold.target.size'='1500'); | ||
|
|
||
| merge into unpart_tbl t | ||
| using (select 1 as id, 'a_upd' as data) s | ||
| on t.id = s.id | ||
| when matched then update set data = s.data; | ||
|
|
||
| SELECT *, ROW__LINEAGE__ID, LAST__UPDATED__SEQUENCE__NUMBER | ||
| FROM unpart_tbl | ||
| ORDER BY ROW__LINEAGE__ID; | ||
|
|
||
| alter table unpart_tbl compact 'major' and wait pool 'iceberg'; | ||
|
|
||
| SELECT *, ROW__LINEAGE__ID, LAST__UPDATED__SEQUENCE__NUMBER | ||
| FROM unpart_tbl | ||
| ORDER BY ROW__LINEAGE__ID; | ||
|
|
||
| show compactions; |
Oops, something went wrong.
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 don't think this logic should kick in like this. If
rowLineageisn't enabled, it should just return*, like before.If
rowLineageis enabled add the name fromROW_LINEAGE_COLUMNS_TO_FILE_NAMEThere 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’ve refactored the code to perform the row lineage check only once and handle all related changes accordingly.