Skip to content

Optimized decoding of Parquet Statistics, null_pages and null_counts #9296

Open

Description

@Dandandan

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Currently, if using statistics, a lot of time can be spent decoding/summarizing the statistics from the ValueStatistics / Statistics structs (which are large / inefficient structs).
In DataFusion this can sometimes take as much time running the query (or more if the query can be answered from statistics directly).

Describe the solution you'd like
We should consider decoding the statistics into a columnar format (values + null bitmap (if needed)) directly, avoiding needing to convert this later (and possibly help decoding as well a bit as well as memory usage).

Looking at ColumnIndex:

pub struct ColumnIndex {
    pub(crate) null_pages: Vec<bool>,
    pub(crate) boundary_order: BoundaryOrder,
    pub(crate) null_counts: Option<Vec<i64>>,
    pub(crate) repetition_level_histograms: Option<Vec<i64>>,
    pub(crate) definition_level_histograms: Option<Vec<i64>>,
}
  • null_pages: this currently is a Vec<bool> (true is null, false is non-null), it would be better to save this as a NullBuffer or similar, where true means valid and false means invalid - this would make it possible to copy the null bitmap without conversion
  • null_counts: Option<Vec>: it would be better to have this as a Int64Array or similar (Or preferably even Uint64Array if we can do the conversion earlier)

Describe alternatives you've considered

Additional context

Activity

  1. added
    enhancement
    performance
    on Jan 29, 2026
  2. changed the title [-]Columnar encoding of statistics[/-] [+]Columnar encoding of Parquet statistics[/+] on Jan 29, 2026
  3. mkleen commented on Jan 29, 2026

    @mkleen
    Contributor

    take

  4. mkleen commented on Jan 30, 2026

    @mkleen
    Contributor

    Can we specify this a little more? This would really help me. Thanks a lot!

  5. changed the title [-]Columnar encoding of Parquet statistics[/-] [+]Optimized encoding of Parquet statistics[/+] on Jan 30, 2026
  6. changed the title [-]Optimized encoding of Parquet statistics[/-] [+]Optimized encoding of Parquet `null_pages` and `null_counts`[/+] on Jan 30, 2026
  7. Dandandan commented on Jan 30, 2026

    @Dandandan
    ContributorAuthor

    Yeah sure - I do understand the needs a bit better after looking at #9303

    Looking at ColumnIndex:

    pub struct ColumnIndex {
        pub(crate) null_pages: Vec<bool>,
        pub(crate) boundary_order: BoundaryOrder,
        pub(crate) null_counts: Option<Vec<i64>>,
        pub(crate) repetition_level_histograms: Option<Vec<i64>>,
        pub(crate) definition_level_histograms: Option<Vec<i64>>,
    }
    
    • null_pages: this currently is a Vec<bool> (true is null, false is non-null), it would be better to save this as a NullBuffer or similar, where true means valid and false means invalid - this would make it possible to copy the null bitmap without conversion and also lowers memory usage a bit
    • null_counts: Option<Vec>: it would be better to have this as a Int64Array or similar (Or preferably even Uint64Array if we can do the conversion earlier)
  8. changed the title [-]Optimized encoding of Parquet `null_pages` and `null_counts`[/-] [+]Optimized decoding of Parquet `null_pages` and `null_counts`[/+] on Jan 30, 2026
  9. alamb commented on Jan 30, 2026

    @alamb
    Contributor

    FYI @etseidl who also has a (potentially unhealthy) fascination with Parquet statistics

  10. changed the title [-]Optimized decoding of Parquet `null_pages` and `null_counts`[/-] [+]Optimized decoding of Parquet Statistics, `null_pages` and `null_counts`[/+] on Feb 2, 2026
  11. alamb commented on Feb 2, 2026

    @alamb
    Contributor

    This also came up here:

    Yes the latter would be best (and preferably also do validation directly on read/convert them to the right type, so it could just pass them on)

  12. alamb commented on Feb 2, 2026

    @alamb
    Contributor

    My personal suggestion is:

    1. Defer decoding statistics entirely when parsing metadata (just skip the statistics)
    2. Decode the statistics directly into arrow arrays (aka the correct columnar format) when requested

    This would solve several sources of inefficiency today:

    1. Many small allocations in ParquetMetadata (one allocation for each page and one for each column for each row group)
    2. Inefficient conversion having to walk down all those little allocations and copy them into an Array
    3. Decoding (w/ allocations) the column statistics for columns that are never read in the queries

    I think the API design is probably the trickiest part of this project

  13. mkleen commented on Mar 23, 2026

    @mkleen
    Contributor

    I would like to resign from this task. I currently don't have enough time to work on this since apache/datafusion#20047 takes me longer than expected.

  14. alamb commented on Mar 24, 2026

    @alamb
    Contributor

    Thanks @mkleen

  15. etseidl commented on Mar 24, 2026

    @etseidl
    Contributor

    There's also #8818 to consider. My issue with doing the conversion here rather than using StatisticsConverter is that we then have an arrow dependency in the parquet metadata. I like @alamb's suggestion...skip parsing the page indexes via ParquetMetaDataPushDecoder and add functionality to the arrow reader to parse the column index straight to arrow arrays. This preserves the current form of the indexes for those not using the arrow reader at all.

  16. mkleen commented on Mar 25, 2026

    @mkleen
    Contributor

    @alamb Can you unassign me please?

  17. mkleen commented on Sep 27, 2026

    @mkleen
    Contributor

    take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementperformance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions