fix(core)!: correct SUM and SUM0 helper results - #1262
Draft
bvolpato wants to merge 1 commit into
Draft
Conversation
Select sum0 in both overloads and derive arithmetic aggregate output types from the configured function declarations. BREAKING CHANGE: SUM widens narrow integer and floating-point results according to the spec. Floating-point SUM0 returns fp64, and sum0(Rel,int) now emits sum0. Custom return declarations are honored by these helpers.
bvolpato
force-pushed
the
bvolpato/fix-sum-helper-types
branch
from
September 4, 2026 16:22
2026afd to
25a08dc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The field overload of sum0 currently emits sum, so an empty input returns null rather than zero. SUM also retains narrow input types instead of using the declared wider result, and floating-point SUM0 incorrectly declares i64.
For an i32 input, these helpers must emit nullable i64 for SUM and the sum0 function with required i64 for SUM0:
Delegate the field overload to sum0 and derive the shared arithmetic helper's output type from its function declaration. This follows spec v0.102.0: integer sums use i64, floating-point sums use fp64, SUM is nullable, and SUM0 is required. Standard MIN/MAX/AVG results retain their existing types.
Downsides
The helpers now follow the supplied extension catalog's return declarations, including custom catalog overrides, rather than imposing their own result types.
BREAKING CHANGE: SUM over i8/i16/i32 or fp32 now reports the spec's wider result type, and floating-point SUM0 reports fp64 instead of i64. Callers that assume the old aggregate output schema must use the returned type. sum0(Rel, int) now emits sum0 rather than sum.