Skip to content

Statistices nested columns - #9775

Open
thorfour wants to merge 3 commits into
vortex-data:developfrom
polarsignals:statistices-nested-columns
Open

Statistices nested columns#9775
thorfour wants to merge 3 commits into
vortex-data:developfrom
polarsignals:statistices-nested-columns

Conversation

@thorfour

@thorfour thorfour commented Sep 4, 2026

Copy link
Copy Markdown

Summary

Being able to perform file level pruning on nested columns speeds up queries.

Changes

Adds post order stats to the file stats footer for nested columns. It adds a new is_nested: bool = false to the stats set flatbuffer for backward compatibility.

Additionally it modifies the way the stats footer is accumulated to use the same AggRef functions that the zone maps use as well.

Only goofy thing it it also has to track truncatable stats separately because the aggregate partials don't have a way to express exactness.

Store file-level statistics via a post-order walk of the DType tree, so
nested struct fields get whole-file pruning instead of only top-level
columns. Each leaf gets a stats entry, and each nullable struct gets a
trailing null-count entry. A new `is_nested` footer flag keeps old files
readable via the legacy top-level-only layout.

Signed-off-by: "Thor" <thor.hansen@dash0.com>
Migrate Min/Max/Sum/NullCount/NaNCount/UncompressedSizeInBytes onto the
same persistent AggregateFnRef/Accumulator framework the zoned layout's
zone-map builder uses, removing the duplicate Stat-enum-keyed
accumulation and its now-dead StatNameArrayBuilder. Utf8/Binary min/max
truncation stays on the bespoke Precision-tracked path, since it needs
per-value exactness that BoundedMax/BoundedMin can't express.

Signed-off-by: "Thor" <thor.hansen@dash0.com>
Cover arbitrary-depth nesting, not just the single level exercised by
the existing tests: postorder layout with mixed nullability across
three levels, StatsNode accumulation contributing a null-count entry
at each nullable level, and whole-file pruning resolving a three-level
field path (x.y.z).

Signed-off-by: "Thor" <thor.hansen@dash0.com>
@codspeed-hq

codspeed-hq Bot commented Sep 7, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 39.37%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
✅ 932 untouched benchmarks
⏩ 1471 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime arrow_checked_add_u32_neon[16384] 20.5 µs 12.8 µs +59.85%
Simulation decompress[u64, (4000, 1024)] 85.5 µs 70.4 µs +21.51%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing polarsignals:statistices-nested-columns (d29bb2a) with develop (a997c3f)

Open in CodSpeed

Footnotes

  1. 1471 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@robert3005

Copy link
Copy Markdown
Contributor

I think for maximum compatibility this has to be a new top level field in https://github.com/vortex-data/vortex/pull/9775/changes#diff-9c5a36ce8f55480706984e8996f192cd3abbdd1b97afa6f702f646b3ce42e039L25. The problem you run into is that old readers already shipped code that make assumption about existing footer statistics. One issue is that they validate field count and if the count doesn't add up they will assume it's a corrupted file. The writer could optionally populate both of the segments and the new version will only ever read the new field.

If you go that route you will see all the places that make assumptions about field stats that need fixing, i.e. datafusion, duckdb and jni

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants