-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Hive: Expose default partition spec and sort order in HMS. #4546
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
Changes from 3 commits
e5cf435
409872b
9bf2a0f
8016618
65cd12c
cceba61
88f8c7f
7c9f0d0
49796e7
fcb5d48
72dc061
0c178a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,40 +41,40 @@ private TableProperties() { | |
| public static final String FORMAT_VERSION = "format-version"; | ||
|
|
||
| /** | ||
| * Reserved table property for UUID. | ||
| * <p> | ||
| * This reserved property is used to store the UUID of the table. | ||
| * Reserved table property for table UUID. | ||
| */ | ||
| public static final String UUID = "uuid"; | ||
|
|
||
| /** | ||
| * Reserved table property for the total number of snapshots. | ||
| * <p> | ||
| * This reserved property is used to store the total number of snapshots. | ||
| */ | ||
| public static final String SNAPSHOT_COUNT = "snapshot-count"; | ||
|
|
||
| /** | ||
| * Reserved table property for current snapshot summary. | ||
| * <p> | ||
| * This reserved property is used to store the current snapshot summary. | ||
| */ | ||
| public static final String CURRENT_SNAPSHOT_SUMMARY = "current-snapshot-summary"; | ||
|
|
||
| /** | ||
| * Reserved table property for current snapshot id. | ||
| * <p> | ||
| * This reserved property is used to store the current snapshot id. | ||
| */ | ||
| public static final String CURRENT_SNAPSHOT_ID = "current-snapshot-id"; | ||
|
|
||
| /** | ||
| * Reserved table property for current snapshot timestamp. | ||
| * <p> | ||
| * This reserved property is used to store the current snapshot timestamp. | ||
| */ | ||
| public static final String CURRENT_SNAPSHOT_TIMESTAMP = "current-snapshot-timestamp-ms"; | ||
|
|
||
| /** | ||
| * Reserved table property for the JSON representation of current partition spec. | ||
| */ | ||
| public static final String DEFAULT_PARTITION_SPEC = "default-partition-spec"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be helpful to clarify what is meant by Each javadoc states that it’s for the “default” spec / sort order, but I’m still not entirely sure what that means. Is it the current sort order / partition spec that would be used if the user doesn’t override it for an individual query ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe something like “JSON representation of the table’s current configured partition spec, which will be used if not overridden for individual writes”. Kind of wordy but something along those lines would be helpful for me if quickly looking through the JavaDocs etc. Will leave that decision to you though.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is for the current partition spec and sort order. Make sense to me. Will make the change.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you reverted too many? Should be 'current'.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to be consistent with the name in metadata.json, which is
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK I see, yea I always find it confusing. In the comment, maybe we can add that they are equivalent, otherwise the comment is even more confusing:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is confusing. I like the |
||
|
|
||
| /** | ||
| * Reserved table property for the JSON representation of current sort order. | ||
| */ | ||
| public static final String DEFAULT_SORT_ORDER = "default-sort-order"; | ||
|
|
||
| /** | ||
| * Reserved Iceberg table properties list. | ||
| * <p> | ||
|
|
@@ -87,7 +87,9 @@ private TableProperties() { | |
| SNAPSHOT_COUNT, | ||
| CURRENT_SNAPSHOT_ID, | ||
| CURRENT_SNAPSHOT_SUMMARY, | ||
| CURRENT_SNAPSHOT_TIMESTAMP | ||
| CURRENT_SNAPSHOT_TIMESTAMP, | ||
| DEFAULT_PARTITION_SPEC, | ||
| DEFAULT_SORT_ORDER | ||
| ); | ||
|
|
||
| public static final String COMMIT_NUM_RETRIES = "commit.retry.num-retries"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,8 +52,10 @@ | |||||||||||||
| import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants; | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two other suggestion for this class: can we add in comment of "HIVE_TABLE_PROPERTY_MAX_SIZE" , one more sentence to let user know how to turn off feature? And also, a precondition in HiveTableOperations constructor to check if value is non-negative.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #4546 (comment).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the comment. Negative is fine, right?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think probably better to disallow negative as it makes little sense? But to me its ok either way.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would throwing exception be too much in that case? May just log a warning. |
||||||||||||||
| import org.apache.iceberg.BaseMetastoreTableOperations; | ||||||||||||||
| import org.apache.iceberg.ClientPool; | ||||||||||||||
| import org.apache.iceberg.PartitionSpecParser; | ||||||||||||||
| import org.apache.iceberg.Snapshot; | ||||||||||||||
| import org.apache.iceberg.SnapshotSummary; | ||||||||||||||
| import org.apache.iceberg.SortOrderParser; | ||||||||||||||
| import org.apache.iceberg.TableMetadata; | ||||||||||||||
| import org.apache.iceberg.TableProperties; | ||||||||||||||
| import org.apache.iceberg.exceptions.AlreadyExistsException; | ||||||||||||||
|
|
@@ -399,6 +401,8 @@ private void setHmsTableParameters(String newMetadataLocation, Table tbl, TableM | |||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| setSnapshotStats(metadata, parameters); | ||||||||||||||
| setPartitionSpec(metadata, parameters); | ||||||||||||||
| setSortOrder(metadata, parameters); | ||||||||||||||
|
|
||||||||||||||
| tbl.setParameters(parameters); | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -433,6 +437,20 @@ void setSnapshotSummary(Map<String, String> parameters, Snapshot currentSnapshot | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private void setPartitionSpec(TableMetadata metadata, Map<String, String> parameters) { | ||||||||||||||
| parameters.remove(TableProperties.DEFAULT_PARTITION_SPEC); | ||||||||||||||
| if (metadata.spec() != null && metadata.spec().isPartitioned()) { | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [question] In v1 spec when a partition is dropped it is replaced by VoidTransform, if all the transforms are void we should consider it un-partitioned (This may be beyond the scope of present PR), but presently when we call isPartitioned it will return true in this case. do we want to store partition spec in this scenario ? Your thoughts. This is based on ticket #3014 @RussellSpitzer filed a while back.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @singhpk234 for pointing out. #3059 is trying to fix #3014, and it is almost ready to merge. It should be fine in that case. |
||||||||||||||
| parameters.put(TableProperties.DEFAULT_PARTITION_SPEC, PartitionSpecParser.toJsonWithSourceName(metadata.spec())); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private void setSortOrder(TableMetadata metadata, Map<String, String> parameters) { | ||||||||||||||
| parameters.remove(TableProperties.DEFAULT_SORT_ORDER); | ||||||||||||||
| if (metadata.sortOrder() != null && metadata.sortOrder().isSorted()) { | ||||||||||||||
| parameters.put(TableProperties.DEFAULT_SORT_ORDER, SortOrderParser.toJson(metadata.sortOrder())); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+471
to
+476
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] should we make this : iceberg/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java Lines 425 to 430 in 449a743
also use this setter
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was trying to do that, but the warn message needs snapshot id here. But it requires changes for method |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private StorageDescriptor storageDescriptor(TableMetadata metadata, boolean hiveEngineEnabled) { | ||||||||||||||
|
|
||||||||||||||
| final StorageDescriptor storageDescriptor = new StorageDescriptor(); | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.