-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Core: Files table predicate filtering wrong for tables with evolved partition specs #4520
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
aokolnychyi
merged 6 commits into
apache:master
from
szehon-ho:metadata_predicate_evolving_spec
Apr 13, 2022
+435
−39
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
13a20c5
Core: Fix metadata table predicate filtering for tables with evolved …
szehon-ho 9e4eed4
Disallow query of old partition spec keys
szehon-ho 446627d
Make optimizations for V2 and add tests and limitations for V1
szehon-ho b9ccb41
Fix transformSpec
szehon-ho 9e3ab98
Revert V1 specific logic and add test to ensure same results in V1 an…
szehon-ho ad0c349
Address review comments
szehon-ho 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,6 @@ | |
| * deserialization. | ||
| */ | ||
| abstract class BaseMetadataTable implements Table, HasTableOperations, Serializable { | ||
| protected static final String PARTITION_FIELD_PREFIX = "partition."; | ||
| private final PartitionSpec spec = PartitionSpec.unpartitioned(); | ||
| private final SortOrder sortOrder = SortOrder.unsorted(); | ||
| private final TableOperations ops; | ||
|
|
@@ -52,18 +51,17 @@ protected BaseMetadataTable(TableOperations ops, Table table, String name) { | |
| * This method transforms the table's partition spec to a spec that is used to rewrite the user-provided filter | ||
| * expression against the given metadata table. | ||
| * <p> | ||
| * The resulting partition spec maps $partitionPrefix.X fields to partition X using an identity partition transform. | ||
| * The resulting partition spec maps partition.X fields to partition X using an identity partition transform. | ||
| * When this spec is used to project an expression for the given metadata table, the projection will remove | ||
| * predicates for non-partition fields (not in the spec) and will remove the "$partitionPrefix." prefix from fields. | ||
| * predicates for non-partition fields (not in the spec) and will remove the "partition." prefix from fields. | ||
| * | ||
| * @param metadataTableSchema schema of the metadata table | ||
| * @param spec spec on which the metadata table schema is based | ||
| * @param partitionPrefix prefix to remove from each field in the partition spec | ||
| * @return a spec used to rewrite the metadata table filters to partition filters using an inclusive projection | ||
| */ | ||
| static PartitionSpec transformSpec(Schema metadataTableSchema, PartitionSpec spec, String partitionPrefix) { | ||
| static PartitionSpec transformSpec(Schema metadataTableSchema, PartitionSpec spec) { | ||
| PartitionSpec.Builder identitySpecBuilder = PartitionSpec.builderFor(metadataTableSchema).checkConflicts(false); | ||
| spec.fields().forEach(pf -> identitySpecBuilder.identity(partitionPrefix + pf.name(), pf.name())); | ||
| spec.fields().forEach(pf -> identitySpecBuilder.add(pf.fieldId(), pf.name(), "identity")); | ||
|
Member
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. This uses the field id to do the transform from metadata table schema to table schema to catch partition field rename cases (old way was to manual remove 'partition.' from the field name). From the suggestion: #4520 (comment) |
||
| return identitySpecBuilder.build(); | ||
| } | ||
|
|
||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.