feat: Implement columnStatistics() for Nimble SelectiveNimbleReader to enable file-level filter pushdown#627
Open
kewang1024 wants to merge 1 commit intofacebookincubator:mainfrom
Open
Conversation
|
@kewang1024 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D98945345. |
6d2cf0e to
f192fd2
Compare
…o enable file-level filter pushdown
Summary:
Nimble writes rich file-level column statistics via VectorizedFileStats
(min/max/count/nullCount per column for integer, floating-point, and
string types) in the "columnar.vectorized_stats" optional section.
However, SelectiveNimbleReader::columnStatistics() returns nullptr,
which means Nimble files cannot participate in file-level filter
pushdown — the mechanism used in HiveConnectorUtil::testFilters() to
skip entire files whose stats prove no rows can match the query filter.
This diff bridges the gap by implementing columnStatistics() in
SelectiveNimbleReader:
- Adds toCommonColumnStatistics() helper that converts
nimble::ColumnStatistics to dwio::common::ColumnStatistics subclasses:
- IntegralStatistics -> IntegerColumnStatistics (min/max)
- FloatingPointStatistics -> DoubleColumnStatistics (min/max)
- StringStatistics -> StringColumnStatistics (min/max)
- Base ColumnStatistics -> base ColumnStatistics (valueCount/hasNull/size)
- Loads VectorizedFileStats in ReaderBase at construction time,
exposed via fileColumnStats(). This is shared by both columnStatistics()
(for file-level filter pushdown) and computeStatsBasedRowSize()
(for row size estimation), eliminating duplicate stats loading.
End-to-end call chain for file-level filter pushdown:
```
Query with filter WHERE col > 200 on a Nimble file with col values [0, 100]:
SplitReader::prepareSplit()
-> checkIfSplitIsEmpty()
-> filterOnStats()
-> testFilters()
-> reader->columnStatistics(colId)
-> [NEW] ReaderBase::fileColumnStats() (loaded at construction)
-> [NEW] toCommonColumnStatistics() converts to IntegerColumnStatistics{min=0, max=100}
-> testFilter(filter=">200", stats={min=0, max=100}, ...)
-> testInt64Range(0, 100, mayHaveNull) returns false
-> return false -> FILE SKIPPED
```
Differential Revision: D98945345
f192fd2 to
59d2a02
Compare
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.
Summary:
Nimble writes rich file-level column statistics via VectorizedFileStats
(min/max/count/nullCount per column for integer, floating-point, and
string types) in the "columnar.vectorized_stats" optional section.
However, SelectiveNimbleReader::columnStatistics() returns nullptr,
which means Nimble files cannot participate in file-level filter
pushdown — the mechanism used in HiveConnectorUtil::testFilters() to
skip entire files whose stats prove no rows can match the query filter.
This diff bridges the gap by implementing columnStatistics() in
SelectiveNimbleReader:
nimble::ColumnStatistics to dwio::common::ColumnStatistics subclasses:
exposed via fileColumnStats(). This is shared by both columnStatistics()
(for file-level filter pushdown) and computeStatsBasedRowSize()
(for row size estimation), eliminating duplicate stats loading.
End-to-end call chain for file-level filter pushdown:
Differential Revision: D98945345