[HUDI-8208] Fix partition stats bound when compacting or clustering#12050
[HUDI-8208] Fix partition stats bound when compacting or clustering#12050codope merged 9 commits intoapache:masterfrom
Conversation
14035d7 to
5a63604
Compare
a94bb1f to
ed3ce0f
Compare
lokeshj1703
left a comment
There was a problem hiding this comment.
Thanks for working on this @codope! I have one comment inline.
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java
Show resolved
Hide resolved
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java
Show resolved
Hide resolved
ed3ce0f to
8efbfcb
Compare
| } | ||
| } | ||
|
|
||
| public static HoodieDataBlock getDataBlock(HoodieLogBlockType dataBlockType, List<IndexedRecord> records, |
There was a problem hiding this comment.
The method here and below are moved to HoodieCommonTestHarness for better reusability.
...ce/hudi-spark/src/test/scala/org/apache/hudi/functional/TestPartitionStatsIndexWithSql.scala
Outdated
Show resolved
Hide resolved
Are you saying instead of using the native min_max range for columns in files generated from compaction and clustering, we recompute the column stats ranges from the source files? For example if we have f1 with range [v1, v2] and f2 with range [v3, v4], instead of using [v1, v4] as the compaction file range, we still use the composition of [v1, v2] and [v3, v4] ? |
For the files generated from compaction and clustering, we were already using the native min, max range. But, we ignored the files that were not compacted or clustered from the partition stats update. If, luckily, all the file slices in a partition were compacted or clustered, then the partition stats would have a tight bound even without this patch. |
...ce/hudi-spark/src/test/scala/org/apache/hudi/functional/TestPartitionStatsIndexWithSql.scala
Outdated
Show resolved
Hide resolved
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java
Show resolved
Hide resolved
| if (shouldScanColStatsForTightBound) { | ||
| tableMetadata = HoodieTableMetadata.create(engineContext, dataMetaClient.getStorage(), metadataConfig, dataMetaClient.getBasePath().toString()); | ||
| } else { | ||
| tableMetadata = null; |
There was a problem hiding this comment.
can we move the below logic within this if block only.
trying to avoid doing null assignment to tableMetadata.
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java
Show resolved
Hide resolved
Ok, you are talking about partition stats specifically, but I still feel the partition stats data structure should support idempotent update for the files, if the file is not involved in the compaction/clustering, there is no need to update the stats for it, the clustering and compaction does not change any partition path of the table. |
8efbfcb to
fde8646
Compare
| .sinceVersion("1.0.0") | ||
| .withDocumentation("Parallelism to use, when generating partition stats index."); | ||
|
|
||
| public static final ConfigProperty<Boolean> ENABLE_PARTITION_STATS_INDEX_TIGHT_BOUND = ConfigProperty |
There was a problem hiding this comment.
do we even need this config to be exposed to user?
should we keep it internal?
There was a problem hiding this comment.
we can take this up separately. not blocking this patch for now
Change Logs
The [min, max] range in column stats or partition stats can keep widening with udpates or deletes, because we simply take min of all mins' and max of maxs' while merging the stats. This can lead to a degenerative case where all partitions qualify for a predicate based on stats, even though actually very few partitions meet the predicate based on actual data. It defeats the purpose of pruning/skipping using stats. To fix this problem, we need to bring the range to a tighter bound. In order to do so, this PR:
isTightBound- to indicate whether min/max range is a tighter bound based on latest snapshot or not. It is false by default and set to true during compaction or clustering.HoodieTableMetadataUtil.Impact
More effective partition pruning for non-partition key fields.
Risk level (write none, low medium or high below)
medium
Scans unmerged log records during compaction or clustering.
Documentation Update
Describe any necessary documentation update if there is any new feature, config, or user-facing change. If not, put "none".
ticket number here and follow the instruction to make
changes to the website.
Contributor's checklist