Skip to content

fix: Cast aggregation to Float64 in coalesce with default_value_double#7908

Draft
volokluev wants to merge 2 commits intomasterfrom
claude/fix-coalesce-type-mismatch-d43e2a4a
Draft

fix: Cast aggregation to Float64 in coalesce with default_value_double#7908
volokluev wants to merge 2 commits intomasterfrom
claude/fix-coalesce-type-mismatch-d43e2a4a

Conversation

@volokluev
Copy link
Copy Markdown
Member

When a conditional_aggregation has default_value_double set, the code wraps the aggregation in coalesce(expr, default_value_double). For functions like uniqIfOrNull which return UInt64, ClickHouse rejects the coalesce because UInt64 and Float64 have no common supertype (error 386).

Fix: CAST the aggregation expression to Float64 before passing to coalesce when default_value_double is used. This ensures type compatibility:
Before: coalesce(uniqIfOrNull(...), 0.0) -- UInt64 vs Float64 FAILS
After: coalesce(CAST(uniqIfOrNull(...) AS Float64), 0.0) -- both Float64

Applied to both trace_item_table and time_series resolvers.

Fixes SNUBA-APG

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

claude and others added 2 commits April 27, 2026 21:31
When a conditional_aggregation has default_value_double set, the code wraps
the aggregation in coalesce(expr, default_value_double). For functions like
uniqIfOrNull which return UInt64, ClickHouse rejects the coalesce because
UInt64 and Float64 have no common supertype (error 386).

Fix: CAST the aggregation expression to Float64 before passing to coalesce
when default_value_double is used. This ensures type compatibility:
  Before: coalesce(uniqIfOrNull(...), 0.0)      -- UInt64 vs Float64 FAILS
  After:  coalesce(CAST(uniqIfOrNull(...) AS Float64), 0.0)  -- both Float64

Applied to both trace_item_table and time_series resolvers.

Fixes SNUBA-APG
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