voonhous opened a new pull request, #21103:
URL: https://github.com/apache/hudi/pull/21103

   ### Describe the issue this Pull Request addresses
   
   Closes #21102. Part of #20449.
   
   On a METADATA_ONLY bootstrapped table, an expression index was built from 
the bootstrap skeleton files alone. A skeleton file only holds the meta 
columns, so the indexed data column was read as all null. The resulting stats 
look like a genuine all-null column (null count = value count), so data 
skipping on the expression index pruned files that hold matching rows: 
`upper(driver) = 'DRIVER_5'` returned 0 rows with data skipping on and 1 row 
with it off, for COW and MOR.
   
   The file system view already attaches the bootstrap source file to a 
skeleton base file. `ExpressionIndexer#buildInitialization` dropped it when it 
turned each file slice into a `FileInfoAndPartition` (path and size only), and 
`SparkMetadataWriterUtils#getExpressionIndexRecordsIterator` rebuilt the base 
file as `new HoodieBaseFile(filePath)`, so the file group reader read the 
skeleton file with the data schema.
   
   ### Summary and Changelog
   
   - `FileInfoAndPartition` carries the optional bootstrap source file of a 
base file.
   - `ExpressionIndexer#buildInitialization` passes the bootstrap source file 
that the file system view attached to the base file of each latest file slice.
   - `SparkMetadataWriterUtils#getExpressionIndexRecordsIterator` sets it on 
the `HoodieBaseFile`, so the file group reader merges the skeleton file with 
its source file, as other readers of bootstrapped file slices do.
   - The column stats and bloom filter variants of the expression index, and 
the partition stats of a column stats expression index, are built from the same 
rows and are fixed together.
   - No extra lookup: the bootstrap source file is only present for skeleton 
files, which the view already resolves. Non-bootstrapped tables, FULL_RECORD 
bootstraps and files rewritten after the bootstrap carry none and are read as 
before. Log files are unchanged.
   - The update path indexes the files written by a commit, which are never 
skeleton files, so it needs no change.
   - Tests:
     - `TestDataSourceForBootstrap#testMetadataBootstrapExpressionIndex` (COW 
and MOR): METADATA_ONLY bootstrap, `create index ... using column_stats(driver) 
options(expr='upper')`, optionally followed by an upsert into a bootstrapped 
partition, then compares equality and range filters on `upper(driver)` with 
data skipping on and off (in `strict` data skipping failure mode). On master 
every case fails with `upper(driver) = 'DRIVER_5' ==> expected: 
<[[...,trip_5,...]]> but was: <[]>`.
     - 
`TestExpressionIndexer#testInitializeKeepsBootstrapBaseFileOfSkeletonFile` 
checks that initialization passes the bootstrap source file of a skeleton file 
to the engine.
   
   ### Impact
   
   Data skipping on an expression index of a METADATA_ONLY bootstrapped table 
no longer drops matching rows. Expression indexes already built on such a table 
keep their wrong stats until they are rebuilt (drop and create the index).
   
   ### Risk Level
   
   low
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to