Skip to content

feat: Implement columnStatistics() for Nimble SelectiveNimbleReader to enable file-level filter pushdown#627

Open
kewang1024 wants to merge 1 commit intofacebookincubator:mainfrom
kewang1024:export-D98945345
Open

feat: Implement columnStatistics() for Nimble SelectiveNimbleReader to enable file-level filter pushdown#627
kewang1024 wants to merge 1 commit intofacebookincubator:mainfrom
kewang1024:export-D98945345

Conversation

@kewang1024
Copy link
Copy Markdown
Contributor

@kewang1024 kewang1024 commented Mar 31, 2026

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

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 31, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Mar 31, 2026

@kewang1024 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D98945345.

@kewang1024 kewang1024 force-pushed the export-D98945345 branch 4 times, most recently from 6d2cf0e to f192fd2 Compare April 1, 2026 07:51
…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
@meta-codesync meta-codesync bot changed the title Implement columnStatistics() for Nimble SelectiveNimbleReader to enable file-level filter pushdown feat: Implement columnStatistics() for Nimble SelectiveNimbleReader to enable file-level filter pushdown Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant