[HUDI-5276] Fix getting partition paths under relative paths#7744
Merged
codope merged 3 commits intoapache:masterfrom Jan 25, 2023
Merged
[HUDI-5276] Fix getting partition paths under relative paths#7744codope merged 3 commits intoapache:masterfrom
codope merged 3 commits intoapache:masterfrom
Conversation
yihua
commented
Jan 24, 2023
| // In that case, we simply could not apply partition pruning and will have to regress to scanning | ||
| // the whole table | ||
| if (haveProperPartitionValues(partitionPaths)) { | ||
| if (haveProperPartitionValues(partitionPaths) && partitionSchema.nonEmpty) { |
Contributor
Author
There was a problem hiding this comment.
This fix is needed for the case where the partition column value has slashes (partition column values are not supposed to be filled), and the query predicates cover all the partition columns, so the exact matching of a partition path happens and partition values are filled inside partitionPaths (see below code snippet from SparkHoodieTableFileIndex#tryListByPartitionPathPrefix).
if (staticPartitionColumnNameValuePairs.length == partitionColumnNames.length) {
// In case composed partition path is complete, we can return it directly avoiding extra listing operation
Seq(new PartitionPath(relativePartitionPathPrefix, staticPartitionColumnNameValuePairs.map(_._2.asInstanceOf[AnyRef]).toArray))
}
Without this fix, the test case 3 (with predicate "dt = '2023/01/01' and region_code = '1'") in testFileListingWithPartitionPrefixPruning would fail.
hudi-common/src/main/java/org/apache/hudi/metadata/FileSystemBackedTableMetadata.java
Outdated
Show resolved
Hide resolved
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java
Outdated
Show resolved
Hide resolved
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java
Outdated
Show resolved
Hide resolved
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadata.java
Show resolved
Hide resolved
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadata.java
Outdated
Show resolved
Hide resolved
alexeykudinkin
approved these changes
Jan 25, 2023
Collaborator
Contributor
fengjian428
pushed a commit
to fengjian428/hudi
that referenced
this pull request
Jan 31, 2023
…7744) This PR made the following change to correct the issue: - Renames `getPartitionPathsWithPrefixes` to `getPartitionPathWithPathPrefixes` in `HoodieTableMetadata` and update relevant variable naming and docs - Fixes the logic in `HoodieBackedTableMetadata#getPartitionPathWithPathPrefixes` to do exact parent directory matching - Adds new tests in `TestHoodieFileIndex` to guard around the logic. These tests fail before this PR.
fengjian428
pushed a commit
to fengjian428/hudi
that referenced
this pull request
Apr 5, 2023
…7744) This PR made the following change to correct the issue: - Renames `getPartitionPathsWithPrefixes` to `getPartitionPathWithPathPrefixes` in `HoodieTableMetadata` and update relevant variable naming and docs - Fixes the logic in `HoodieBackedTableMetadata#getPartitionPathWithPathPrefixes` to do exact parent directory matching - Adds new tests in `TestHoodieFileIndex` to guard around the logic. These tests fail before this PR.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Change Logs
When the metadata table is enabled and used for getting the partition paths under certain directories (listing by partition path prefix in
SparkHoodieTableFileIndexand getting query partition paths inBaseHoodieTableFileIndex), the following logic inHoodieBackedTableMetadatais invokedIf all the partition paths contain
1,10, and100, listing using1returns all three, which is incorrect. Theprefixesshould serve as the exact relative path and the naming itself is misleading.This PR made the following change to correct the issue:
getPartitionPathsWithPrefixestogetPartitionPathWithPathPrefixesinHoodieTableMetadataand update relevant variable naming and docsHoodieBackedTableMetadata#getPartitionPathWithPathPrefixesto do exact parent directory matchingTestHoodieFileIndexto guard around the logic. These tests fail before this PR.This PR fixes #7298.
Impact
Fixes the bug of getting irrelevant partition paths given a relative path/prefix.
Risk level
low
Documentation Update
N/A
Contributor's checklist