-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29342: Iceberg: [V3] Display initial and write defaults in descr… #6367
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
tanishq-chugh
wants to merge
8
commits into
apache:master
Choose a base branch
from
tanishq-chugh:HIVE-29342
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.
+374
−4
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5101e6b
HIVE-29342: Iceberg: [V3] Display initial and write defaults in descr…
tanishq-chugh a940f5e
Fix NPE caused for non iceberg DESC formatted table queries
tanishq-chugh 4f14c35
Revert "Fix NPE caused for non iceberg DESC formatted table queries"
tanishq-chugh 9f6fd28
Revert "HIVE-29342: Iceberg: [V3] Display initial and write defaults …
tanishq-chugh 8dbc28b
Refactor Code to add defaults in Defaults Constraint section of Descr…
tanishq-chugh 7b39099
Remove unused import
tanishq-chugh fb631f0
Fix sonarqube issue
tanishq-chugh 48fa649
Update qtest after rebase
tanishq-chugh 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
44 changes: 44 additions & 0 deletions
44
iceberg/iceberg-handler/src/test/queries/positive/iceberg_defaults_in_desc_table.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,44 @@ | ||
| -- Mask random uuid | ||
| --! qt:replace:/(\s+uuid\s+)\S+(\s*)/$1#Masked#$2/ | ||
| -- Mask a random snapshot id | ||
| --! qt:replace:/(\s+current-snapshot-id\s+)\S+(\s*)/$1#Masked#/ | ||
| -- Mask added file size | ||
| --! qt:replace:/(\S\"added-files-size\\\":\\\")(\d+)(\\\")/$1#Masked#$3/ | ||
| -- Mask total file size | ||
| --! qt:replace:/(\S\"total-files-size\\\":\\\")(\d+)(\\\")/$1#Masked#$3/ | ||
| -- Mask current-snapshot-timestamp-ms | ||
| --! qt:replace:/(\s+current-snapshot-timestamp-ms\s+)\S+(\s*)/$1#Masked#$2/ | ||
|
|
||
| CREATE TABLE ice_parq ( | ||
| id INT) | ||
| STORED BY ICEBERG stored as parquet | ||
| TBLPROPERTIES ('format-version'='3'); | ||
|
|
||
| INSERT INTO ice_parq (id) VALUES (1); | ||
|
|
||
| ALTER TABLE ice_parq ADD COLUMNS (point STRUCT<x:INT, y:INT> DEFAULT '{"x":100,"y":99}', | ||
| name STRING DEFAULT 'unknown', | ||
| age INT DEFAULT 25); | ||
|
|
||
| INSERT INTO ice_parq (id) VALUES (2); | ||
|
|
||
| SELECT * FROM ice_parq ORDER BY id; | ||
|
|
||
| DESCRIBE FORMATTED ice_parq; | ||
|
|
||
| CREATE TABLE ice_orc ( | ||
| id INT) | ||
| STORED BY ICEBERG stored as orc | ||
| TBLPROPERTIES ('format-version'='3'); | ||
|
|
||
| INSERT INTO ice_orc (id) VALUES (1); | ||
|
|
||
| ALTER TABLE ice_orc ADD COLUMNS (point STRUCT<x:INT, y:INT> DEFAULT '{"x":100,"y":99}', | ||
| name STRING DEFAULT 'unknown', | ||
| age INT DEFAULT 25); | ||
|
|
||
| INSERT INTO ice_orc (id) VALUES (2); | ||
|
|
||
| SELECT * FROM ice_orc ORDER BY id; | ||
|
|
||
| DESCRIBE FORMATTED ice_orc; |
238 changes: 238 additions & 0 deletions
238
iceberg/iceberg-handler/src/test/results/positive/iceberg_defaults_in_desc_table.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,238 @@ | ||
| PREHOOK: query: CREATE TABLE ice_parq ( | ||
| id INT) | ||
| STORED BY ICEBERG stored as parquet | ||
| TBLPROPERTIES ('format-version'='3') | ||
| PREHOOK: type: CREATETABLE | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@ice_parq | ||
| POSTHOOK: query: CREATE TABLE ice_parq ( | ||
| id INT) | ||
| STORED BY ICEBERG stored as parquet | ||
| TBLPROPERTIES ('format-version'='3') | ||
| POSTHOOK: type: CREATETABLE | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@ice_parq | ||
| PREHOOK: query: INSERT INTO ice_parq (id) VALUES (1) | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: _dummy_database@_dummy_table | ||
| PREHOOK: Output: default@ice_parq | ||
| POSTHOOK: query: INSERT INTO ice_parq (id) VALUES (1) | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: _dummy_database@_dummy_table | ||
| POSTHOOK: Output: default@ice_parq | ||
| PREHOOK: query: ALTER TABLE ice_parq ADD COLUMNS (point STRUCT<x:INT, y:INT> DEFAULT '{"x":100,"y":99}', | ||
| name STRING DEFAULT 'unknown', | ||
| age INT DEFAULT 25) | ||
| PREHOOK: type: ALTERTABLE_ADDCOLS | ||
| PREHOOK: Input: default@ice_parq | ||
| PREHOOK: Output: default@ice_parq | ||
| POSTHOOK: query: ALTER TABLE ice_parq ADD COLUMNS (point STRUCT<x:INT, y:INT> DEFAULT '{"x":100,"y":99}', | ||
| name STRING DEFAULT 'unknown', | ||
| age INT DEFAULT 25) | ||
| POSTHOOK: type: ALTERTABLE_ADDCOLS | ||
| POSTHOOK: Input: default@ice_parq | ||
| POSTHOOK: Output: default@ice_parq | ||
| PREHOOK: query: INSERT INTO ice_parq (id) VALUES (2) | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: _dummy_database@_dummy_table | ||
| PREHOOK: Output: default@ice_parq | ||
| POSTHOOK: query: INSERT INTO ice_parq (id) VALUES (2) | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: _dummy_database@_dummy_table | ||
| POSTHOOK: Output: default@ice_parq | ||
| PREHOOK: query: SELECT * FROM ice_parq ORDER BY id | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@ice_parq | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: SELECT * FROM ice_parq ORDER BY id | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@ice_parq | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| 1 NULL unknown 25 | ||
| 2 {"x":100,"y":99} unknown 25 | ||
| PREHOOK: query: DESCRIBE FORMATTED ice_parq | ||
| PREHOOK: type: DESCTABLE | ||
| PREHOOK: Input: default@ice_parq | ||
| POSTHOOK: query: DESCRIBE FORMATTED ice_parq | ||
| POSTHOOK: type: DESCTABLE | ||
| POSTHOOK: Input: default@ice_parq | ||
| # col_name data_type comment | ||
| id int | ||
| point struct<x:int,y:int> | ||
| name string | ||
| age int | ||
|
|
||
| # Detailed Table Information | ||
| Database: default | ||
| #### A masked pattern was here #### | ||
| Retention: 0 | ||
| #### A masked pattern was here #### | ||
| Table Type: EXTERNAL_TABLE | ||
| Table Parameters: | ||
| COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\"} | ||
| EXTERNAL TRUE | ||
| bucketing_version 2 | ||
| current-schema {\"type\":\"struct\",\"schema-id\":1,\"fields\":[{\"id\":1,\"name\":\"id\",\"required\":false,\"type\":\"int\"},{\"id\":2,\"name\":\"point\",\"required\":false,\"type\":{\"type\":\"struct\",\"fields\":[{\"id\":3,\"name\":\"x\",\"required\":false,\"type\":\"int\",\"write-default\":100},{\"id\":4,\"name\":\"y\",\"required\":false,\"type\":\"int\",\"write-default\":99}]}},{\"id\":5,\"name\":\"name\",\"required\":false,\"type\":\"string\",\"initial-default\":\"unknown\",\"write-default\":\"unknown\"},{\"id\":6,\"name\":\"age\",\"required\":false,\"type\":\"int\",\"initial-default\":25,\"write-default\":25}]} | ||
| current-snapshot-id #Masked# | ||
| current-snapshot-summary {\"added-data-files\":\"1\",\"added-records\":\"1\",\"added-files-size\":\"#Masked#\",\"changed-partition-count\":\"1\",\"total-records\":\"2\",\"total-files-size\":\"#Masked#\",\"total-data-files\":\"2\",\"total-delete-files\":\"0\",\"total-position-deletes\":\"0\",\"total-equality-deletes\":\"0\",\"iceberg-version\":\"Apache Iceberg 1.10.1 (commit ccb8bc435062171e64bc8b7e5f56e6aed9c5b934)\"} | ||
| current-snapshot-timestamp-ms #Masked# | ||
| format-version 3 | ||
| iceberg.orc.files.only false | ||
| metadata_location hdfs://### HDFS PATH ### | ||
| numFiles 2 | ||
| numRows 2 | ||
| parquet.compression zstd | ||
| previous_metadata_location hdfs://### HDFS PATH ### | ||
| rawDataSize 0 | ||
| serialization.format 1 | ||
| snapshot-count 2 | ||
| storage_handler org.apache.iceberg.mr.hive.HiveIcebergStorageHandler | ||
| table_type ICEBERG | ||
| totalSize #Masked# | ||
| #### A masked pattern was here #### | ||
| uuid #Masked# | ||
| write.delete.mode merge-on-read | ||
| write.format.default parquet | ||
| write.merge.mode merge-on-read | ||
| write.metadata.delete-after-commit.enabled true | ||
| write.update.mode merge-on-read | ||
|
|
||
| # Storage Information | ||
| SerDe Library: org.apache.iceberg.mr.hive.HiveIcebergSerDe | ||
| InputFormat: org.apache.iceberg.mr.hive.HiveIcebergInputFormat | ||
| OutputFormat: org.apache.iceberg.mr.hive.HiveIcebergOutputFormat | ||
| Compressed: No | ||
| Sort Columns: [] | ||
|
|
||
| # Constraints | ||
|
|
||
| # Default Constraints | ||
| Table: default.ice_parq | ||
| Constraint Name: #### A masked pattern was here #### | ||
| Column Name:age Initial Default Value:25 Write Default Value:25 | ||
|
|
||
| Constraint Name: #### A masked pattern was here #### | ||
| Column Name:point Initial Default Value: Write Default Value:'x:100,y:99' | ||
|
|
||
| Constraint Name: #### A masked pattern was here #### | ||
| Column Name:name Initial Default Value:'unknown' Write Default Value:'unknown' | ||
|
|
||
| PREHOOK: query: CREATE TABLE ice_orc ( | ||
| id INT) | ||
| STORED BY ICEBERG stored as orc | ||
| TBLPROPERTIES ('format-version'='3') | ||
| PREHOOK: type: CREATETABLE | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@ice_orc | ||
| POSTHOOK: query: CREATE TABLE ice_orc ( | ||
| id INT) | ||
| STORED BY ICEBERG stored as orc | ||
| TBLPROPERTIES ('format-version'='3') | ||
| POSTHOOK: type: CREATETABLE | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@ice_orc | ||
| PREHOOK: query: INSERT INTO ice_orc (id) VALUES (1) | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: _dummy_database@_dummy_table | ||
| PREHOOK: Output: default@ice_orc | ||
| POSTHOOK: query: INSERT INTO ice_orc (id) VALUES (1) | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: _dummy_database@_dummy_table | ||
| POSTHOOK: Output: default@ice_orc | ||
| PREHOOK: query: ALTER TABLE ice_orc ADD COLUMNS (point STRUCT<x:INT, y:INT> DEFAULT '{"x":100,"y":99}', | ||
| name STRING DEFAULT 'unknown', | ||
| age INT DEFAULT 25) | ||
| PREHOOK: type: ALTERTABLE_ADDCOLS | ||
| PREHOOK: Input: default@ice_orc | ||
| PREHOOK: Output: default@ice_orc | ||
| POSTHOOK: query: ALTER TABLE ice_orc ADD COLUMNS (point STRUCT<x:INT, y:INT> DEFAULT '{"x":100,"y":99}', | ||
| name STRING DEFAULT 'unknown', | ||
| age INT DEFAULT 25) | ||
| POSTHOOK: type: ALTERTABLE_ADDCOLS | ||
| POSTHOOK: Input: default@ice_orc | ||
| POSTHOOK: Output: default@ice_orc | ||
| PREHOOK: query: INSERT INTO ice_orc (id) VALUES (2) | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: _dummy_database@_dummy_table | ||
| PREHOOK: Output: default@ice_orc | ||
| POSTHOOK: query: INSERT INTO ice_orc (id) VALUES (2) | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: _dummy_database@_dummy_table | ||
| POSTHOOK: Output: default@ice_orc | ||
| PREHOOK: query: SELECT * FROM ice_orc ORDER BY id | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@ice_orc | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: SELECT * FROM ice_orc ORDER BY id | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@ice_orc | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| 1 NULL NULL NULL | ||
| 2 {"x":100,"y":99} unknown 25 | ||
| PREHOOK: query: DESCRIBE FORMATTED ice_orc | ||
| PREHOOK: type: DESCTABLE | ||
| PREHOOK: Input: default@ice_orc | ||
| POSTHOOK: query: DESCRIBE FORMATTED ice_orc | ||
| POSTHOOK: type: DESCTABLE | ||
| POSTHOOK: Input: default@ice_orc | ||
| # col_name data_type comment | ||
| id int | ||
| point struct<x:int,y:int> | ||
| name string | ||
| age int | ||
|
|
||
| # Detailed Table Information | ||
| Database: default | ||
| #### A masked pattern was here #### | ||
| Retention: 0 | ||
| #### A masked pattern was here #### | ||
| Table Type: EXTERNAL_TABLE | ||
| Table Parameters: | ||
| COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\"} | ||
| EXTERNAL TRUE | ||
| bucketing_version 2 | ||
| current-schema {\"type\":\"struct\",\"schema-id\":1,\"fields\":[{\"id\":1,\"name\":\"id\",\"required\":false,\"type\":\"int\"},{\"id\":2,\"name\":\"point\",\"required\":false,\"type\":{\"type\":\"struct\",\"fields\":[{\"id\":3,\"name\":\"x\",\"required\":false,\"type\":\"int\",\"write-default\":100},{\"id\":4,\"name\":\"y\",\"required\":false,\"type\":\"int\",\"write-default\":99}]}},{\"id\":5,\"name\":\"name\",\"required\":false,\"type\":\"string\",\"write-default\":\"unknown\"},{\"id\":6,\"name\":\"age\",\"required\":false,\"type\":\"int\",\"write-default\":25}]} | ||
| current-snapshot-id #Masked# | ||
| current-snapshot-summary {\"added-data-files\":\"1\",\"added-records\":\"1\",\"added-files-size\":\"#Masked#\",\"changed-partition-count\":\"1\",\"total-records\":\"2\",\"total-files-size\":\"#Masked#\",\"total-data-files\":\"2\",\"total-delete-files\":\"0\",\"total-position-deletes\":\"0\",\"total-equality-deletes\":\"0\",\"iceberg-version\":\"Apache Iceberg 1.10.1 (commit ccb8bc435062171e64bc8b7e5f56e6aed9c5b934)\"} | ||
| current-snapshot-timestamp-ms #Masked# | ||
| format-version 3 | ||
| iceberg.orc.files.only true | ||
| metadata_location hdfs://### HDFS PATH ### | ||
| numFiles 2 | ||
| numRows 2 | ||
| parquet.compression zstd | ||
| previous_metadata_location hdfs://### HDFS PATH ### | ||
| rawDataSize 0 | ||
| serialization.format 1 | ||
| snapshot-count 2 | ||
| storage_handler org.apache.iceberg.mr.hive.HiveIcebergStorageHandler | ||
| table_type ICEBERG | ||
| totalSize #Masked# | ||
| #### A masked pattern was here #### | ||
| uuid #Masked# | ||
| write.delete.mode merge-on-read | ||
| write.format.default orc | ||
| write.merge.mode merge-on-read | ||
| write.metadata.delete-after-commit.enabled true | ||
| write.update.mode merge-on-read | ||
|
|
||
| # Storage Information | ||
| SerDe Library: org.apache.iceberg.mr.hive.HiveIcebergSerDe | ||
| InputFormat: org.apache.iceberg.mr.hive.HiveIcebergInputFormat | ||
| OutputFormat: org.apache.iceberg.mr.hive.HiveIcebergOutputFormat | ||
| Compressed: No | ||
| Sort Columns: [] | ||
|
|
||
| # Constraints | ||
|
|
||
| # Default Constraints | ||
| Table: default.ice_orc | ||
| Constraint Name: #### A masked pattern was here #### | ||
| Column Name:point Initial Default Value: Write Default Value:'x:100,y:99' | ||
|
|
||
| Constraint Name: #### A masked pattern was here #### | ||
| Column Name:age Initial Default Value: Write Default Value:25 | ||
|
|
||
| Constraint Name: #### A masked pattern was here #### | ||
| Column Name:name Initial Default Value: Write Default Value:'unknown' | ||
|
|
||
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.
Initial Default Should come here in Default Constraints block, not in schema