Skip to content

fix avg time weighted overflow#1122

Merged
yokofly merged 1 commit intodevelopfrom
bugfix/issue-1121-avg-time-weighted-overflow
Mar 6, 2026
Merged

fix avg time weighted overflow#1122
yokofly merged 1 commit intodevelopfrom
bugfix/issue-1121-avg-time-weighted-overflow

Conversation

@yokofly
Copy link
Copy Markdown
Collaborator

@yokofly yokofly commented Mar 6, 2026

Summary

Fix avg_time_weighted incorrect results for signed integer values (issue #1121).

  • For _time_weighted + avg, instantiate nested avg_weighted with Float64 weights.
  • Keep median_time_weighted unchanged (UInt64 weight path).
  • In AggregateFunctionTimeWeighted, support nested weight columns of both UInt64 and Float64.

Root Cause

avg_time_weighted(Int*, time) previously used nested avg_weighted<Value, UInt64>, which could trigger unsigned-promotion/overflow behavior for negative signed inputs.

Compatibility

This PR intentionally does not preserve backward compatibility for previously serialized avg_time_weightedState binary format.
Robust correctness for new computations/merges is prioritized for this fix.

Please write user-readable short description of the changes:
fix #1121

@yokofly yokofly merged commit 183444c into develop Mar 6, 2026
7 of 11 checks passed
@yokofly yokofly deleted the bugfix/issue-1121-avg-time-weighted-overflow branch March 6, 2026 06:01
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.

Unsigned integer overflow in time-weighted aggregation functions

1 participant