Skip to content

Add list_sum expression#8676

Draft
mhk197 wants to merge 2 commits into
developfrom
mk/list-sum-expr
Draft

Add list_sum expression#8676
mhk197 wants to merge 2 commits into
developfrom
mk/list-sum-expr

Conversation

@mhk197

@mhk197 mhk197 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Adds a vortex.list.sum scalar function: the sum of each row's list elements, one output row per input row — the equivalent of DuckDB's list_sum() and DataFusion's array_sum(). It is the simplest member of the list-aggregate family (list_min/list_max/list_avg/…) and establishes the vtable shape, typing rule, and semantics decisions the rest of the family can reuse.

A full design doc is included at vortex-array/src/scalar_fn/fns/list_sum/design.md, covering a survey of DuckDB / DataFusion / ClickHouse / Polars semantics and the decision points. The headline decision: SQL SUM semantics per list (null, empty, and all-null lists yield null; null elements are skipped), chosen because both engines Vortex pushes expressions down to (DuckDB, DataFusion) agree on it, and a pushed-down list_sum returning 0 where the engine returns NULL would silently change query results.

mhk197 added 2 commits July 6, 2026 15:01
Design for a vortex.list.sum scalar function: survey of DuckDB/DataFusion/
ClickHouse/Polars semantics, reuse of the grouped-sum machinery
(GroupedAccumulator), SQL NULL-on-empty semantics for engine pushdown
parity, NaN handling via NumericalAggregateOpts, and version-gated
DataFusion integration (array_sum absent from the pinned DF 54).

Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Implements the vortex.list.sum scalar function per the design doc: sums
each list's elements through the grouped aggregate machinery
(GroupedAccumulator<Sum>) so widening, overflow, and NaN semantics match
sum() exactly, then nulls out empty and all-null lists to follow SQL SUM
semantics (matching DuckDB list_sum and DataFusion array_sum). NaN
handling is controlled by NumericalAggregateOpts, defaulting to
skip_nans like sum().

Signed-off-by: Matt Katz <mhkatz97@gmail.com>
@codspeed-hq

codspeed-hq Bot commented Jul 7, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 12.41%

⚡ 4 improved benchmarks
✅ 1603 untouched benchmarks
⏩ 42 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation compact_sliced[(16384, 90)] 930.6 ns 813.9 ns +14.33%
Simulation bitwise_not_vortex_buffer_mut[128] 244.4 ns 215.3 ns +13.55%
Simulation compact_sliced[(4096, 90)] 867.2 ns 779.7 ns +11.22%
Simulation bitwise_not_vortex_buffer_mut[1024] 304.7 ns 275.6 ns +10.58%

Tip

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


Comparing mk/list-sum-expr (b981b40) with develop (1e91494)

Open in CodSpeed

Footnotes

  1. 42 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.

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.

1 participant