Repository navigation
Commit 3c87da0
Keep the file sum absent when a chunk sum overflows (#10328)
## Summary
- Tracking Issue: #10177
The file writer computes the file `Stat::Sum` in two passes.
`push_chunk` stores each chunk's sum in a nullable column, and
`as_stats_set` sums that column again. Both passes use the legacy `Sum`
aggregate, which returns zero for empty input and null only on overflow.
The second pass skips nulls as if they were missing values, so the
footer could report an exact sum of only the chunks that did not
overflow. For chunks `[i64::MAX, 1]` and `[2]`, the footer reported `2`.
This happens with real data when some chunks overflow and others don't.
Examples: microsecond timestamps stored as plain `i64`, where full
batches overflow but a short last batch does not, or `i64::MAX` /
`u64::MAX` sentinel values that only appear in some chunks.
This replaces #10228 with a much smaller fix.
## Changes
- In `StatsAccumulator::as_stats_set`, leave `Sum` absent when any chunk
sum is null. This follows the existing guard for truncated varlen `Max`
right above it.
- Adds an rstest unit test in `vortex-layout` (one chunk overflows, all
chunks overflow, the total overflows, nullable values, an all-null
chunk) and an end-to-end writer test in `vortex-file` that checks both
the returned footer and the footer read back from the file.
This is a stopgap for the legacy `Stat::Sum` path only. When file
statistics move to aggregate function partials (for example `SumV2`,
which tracks overflow in an explicit `is_overflow` field), chunk results
are merged as partials instead of summed as values, and this guard can
be deleted along with `Stat::Sum`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_014jTJihcDfBHCS9AQcQHLjR
---------
Signed-off-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>1 parent 90c40ee commit 3c87da0
2 files changed
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
2126 | 2127 | | |
2127 | 2128 | | |
2128 | 2129 | | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
2129 | 2165 | | |
2130 | 2166 | | |
2131 | 2167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
161 | 168 | | |
162 | 169 | | |
163 | 170 | | |
| |||
531 | 538 | | |
532 | 539 | | |
533 | 540 | | |
| 541 | + | |
534 | 542 | | |
535 | 543 | | |
536 | 544 | | |
| |||
636 | 644 | | |
637 | 645 | | |
638 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
639 | 676 | | |
0 commit comments