Repository navigation
feat: collect Lance column statistics during writes - #18901
puneetdixit200 wants to merge 1 commit into
Conversation
|
Pushed Root cause: the functional test still asserted that Lance tables must not initialize column/partition stats metadata, but this branch now adds Lance column stats support and the common metadata test expects those partitions to be enabled where applicable. Change:
Local verification:
|
hudi-agent
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.
Thanks for the contribution! This PR adds Lance support to readColumnStatsFromMetadata and removes the gating on the COLUMN_STATS / PARTITION_STATS metadata partitions for Lance tables. The implementation correctly handles null/empty column lists, missing columns, and nested fields, and it follows the same record-iteration pattern used for log files. No correctness issues found. A few style/readability suggestions in the inline comments. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. A few naming and simplification suggestions below.
cc @yihua
|
@rahil-c Can you please take a look at this? |
e734a41 to
b84e6ab
Compare
|
@hudi-bot run azure |
hudi-agent
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.
Thanks for working on this! The PR enables Lance metadata column stats and partition stats by implementing LanceUtils.readColumnStatsFromMetadata via a record-iteration approach (similar to the log file path), routing .lance files in readColumnRangeMetadataFrom, and removing the gates in MetadataPartitionType. One architectural question worth surfacing in the inline comments about the performance trade-off of reading all records. Please take a look at the inline comment, and this should be ready for a Hudi committer or PMC member to take it from here. A couple of small readability suggestions below.
| return Collections.emptyList(); | ||
| } | ||
|
|
||
| List<String> projectedColumns = fieldsToIndex.stream() |
There was a problem hiding this comment.
🤖 This path iterates every record in the file to compute stats. Since the Lance writer doesn't populate writeStat.columnStats, this full-file re-read will be triggered for every newly-written Lance base file on every commit (and for partition-stats aggregation on top of that). For Parquet, the equivalent path is cheap because it reads block-level statistics from the footer. @yihua have you considered (a) populating column stats on the writer side in HoodieBaseLanceWriter like Parquet does, or (b) exposing Lance's native per-fragment column statistics via the Java binding? Either would avoid the per-commit full-scan. Is the intent to land this read-based path now and optimize in a follow-up?
- AI-generated; verify before applying. React 👍/👎 to flag quality.
There was a problem hiding this comment.
This patch keeps the read-based path so Lance column and partition stats can be generated now. The writer-side/native Lance stats path looks like larger follow-up work: the current Lance writer path only writes file data plus bloom/vector metadata, and I do not see an existing HoodieWriteStat column-stats hook to reuse there.
|
@hudi-bot run azure |
hudi-agent
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.
Thanks for working on this! The PR enables column/partition stats for Lance base files by implementing readColumnStatsFromMetadata via a projected record scan and removing the Lance gate from MetadataPartitionType. The control flow, resource cleanup, and downstream contract (one entry per targetFields element, never null) all check out. No new issues flagged from this automated pass — a Hudi committer or PMC member can take it from here for a final review.
cc @yihua
| .map(Pair::getKey) | ||
| .collect(Collectors.toList()); | ||
| HoodieSchema projectedSchema = HoodieSchemaUtils.projectSchema(fileSchema, projectedColumns); | ||
| try (ClosableIterator<HoodieRecord> recordIterator = fileReader.getRecordIterator(projectedSchema)) { |
There was a problem hiding this comment.
you just read the files again, a more proper way is to collect the column stats during the write, we might need to add a hook in base file write to trigger the column stats collection.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #18901 +/- ##
=========================================
Coverage 68.77% 68.78%
- Complexity 29087 29096 +9
=========================================
Files 2517 2517
Lines 139822 139850 +28
Branches 17209 17209
=========================================
+ Hits 96169 96190 +21
- Misses 35880 35888 +8
+ Partials 7773 7772 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Collect per-file ranges after row encoding and metadata population, and carry them in write statistics for metadata indexing. Keep projected reads for index initialization and recovery. Closes apache#18758.
8c17e31 to
00fe622
Compare
Describe the issue this Pull Request addresses
Closes #18758.
Summary and Changelog
Collect Lance column ranges as records are written, then pass them to the metadata index through
HoodieWriteStat. This addresses the request to avoid reading newly written files again.Impact
Lance tables can use the existing column-stats configuration and, when partitioned, the partition-stats index. The writer interface gains a default callback method. No new configuration keys or file-format changes are introduced.
Risk Level
medium
This enables metadata indexes that affect file and partition pruning. Tests cover populated and omitted metadata fields, nulls, reused input buffers, both index versions, and SQL inserts, updates, deletes, and compaction for partitioned and unpartitioned COW/MOR tables.
Documentation Update
Companion update to
website/docs/metadata_indexing.mdonasf-site: #20440Contributor's checklist
Validation
187 tests passed with no failures or skips on Java 17: common (94), Hadoop metadata utilities (19), collector/indexer (12), Spark (31), and Flink (31). Checkstyle, license checks, and
git diff --checkpassed.The local test classpath needed
hadoop-client-runtime-3.3.5.jaralongside the resolved Hadoop client API. No dependency declarations were changed. In the commands below,HADOOP_TEST_RUNTIMEpoints to that jar.The full project test suite was not run.