Repository navigation
Enable use_variant_as_common_type by default - #90677
Merged
Merged
Conversation
Contributor
|
Workflow [PR], commit [495a0f6] Summary: ❌
|
serxa
approved these changes
Nov 24, 2025
Remove `NO_COMMON_TYPE` error expectations from queries that now succeed when `use_variant_as_common_type` is enabled by default. Update the reference file with expected Variant type outputs. Co-Authored-By: Claude Opus 4.5 <[email protected]>
The test expected an exception when using mixed types (string and integer) in an array literal for `NOT IN`, but now arrays can use Variant as the common type, so the query succeeds. Co-Authored-By: Claude Opus 4.5 <[email protected]>
This was referenced Jun 8, 2026
groeneai
added a commit
to groeneai/ClickHouse
that referenced
this pull request
Jun 11, 2026
…types Since use_variant_as_common_type became the default (ClickHouse#90677), if/multiIf/ coalesce/ifNull/array/map over mixed numeric branches that have no lossless common type (for example a Decimal and a Float64, or an Int64 and a Float64) produce a Variant. Value-combining aggregate functions (sum, avg, min, max) reject a Variant argument, so an expression like sum(if(1, toDecimal64(1, 2), 0.)) fails with ILLEGAL_TYPE_OF_ARGUMENT. This is not a regression: the same query threw NO_COMMON_TYPE before ClickHouse#90677, only the error text changed. This adds a new setting allow_lossy_numeric_supertype, disabled by default. When enabled, getLeastSupertypeOrVariant first tries the lossless common type; if there is none and every branch is numeric with at least one floating point branch, it resolves to Float64 (matching binary arithmetic promotion) instead of building a Variant, so the result can be aggregated. Integer-only sets that lack a common type (for example Int64 and UInt64) keep producing a Variant because there is no obvious lossy numeric supertype. The setting is threaded through if/multiIf/coalesce/ifNull/array/map and the MultiIfToIf / IfChainToMultiIf analyzer passes. The aggregate functions sum, avg, min and max now mention the setting in their "illegal type" error when the rejected argument is an all-numeric Variant, so users get a clear escape hatch. allow_lossy_numeric_supertype is a behavior opt-in, not an experimental gate, so it is whitelisted in check_style/experimental_settings_ignore.txt rather than added to enableAllExperimentalSettings.cpp. Closes ClickHouse#106707 Co-Authored-By: Claude Opus 4.8 <[email protected]>
groeneai
added a commit
to groeneai/ClickHouse
that referenced
this pull request
Jun 11, 2026
…types Since use_variant_as_common_type became the default (ClickHouse#90677), if/multiIf/ coalesce/ifNull/array/map over mixed numeric branches that have no lossless common type (for example a Decimal and a Float64, or an Int64 and a Float64) produce a Variant. Value-combining aggregate functions (sum, avg, min, max) reject a Variant argument, so an expression like sum(if(1, toDecimal64(1, 2), 0.)) fails with ILLEGAL_TYPE_OF_ARGUMENT. This is not a regression: the same query threw NO_COMMON_TYPE before ClickHouse#90677, only the error text changed. This adds a new setting allow_lossy_numeric_supertype, disabled by default. When enabled, getLeastSupertypeOrVariant first tries the lossless common type; if there is none and every branch is numeric with at least one floating point branch, it resolves to Float64 (matching binary arithmetic promotion) instead of building a Variant, so the result can be aggregated. NULL-only branches (a bare NULL literal, Nullable(Nothing)) are skipped while nullability is tracked, so a normal conditional shape such as multiIf(c1, NULL, c2, toDecimal64(1, 2), 0.) resolves to Nullable(Float64) instead of falling through to a Variant. Integer-only sets that lack a common type (for example Int64 and UInt64) keep producing a Variant because there is no obvious lossy numeric supertype. The setting is threaded through if/multiIf/coalesce/ifNull/array/map and the MultiIfToIf / IfChainToMultiIf analyzer passes. The aggregate functions sum, avg, min and max now mention the setting in their "illegal type" error when enabling it would actually replace the rejected Variant with a numeric supertype (all-numeric alternatives with at least one floating point branch); the hint reuses the fallback eligibility check, so it is not shown for integer-only Variants that the setting cannot help. allow_lossy_numeric_supertype is a behavior opt-in, not an experimental gate, so it is whitelisted in check_style/experimental_settings_ignore.txt rather than added to enableAllExperimentalSettings.cpp. Closes ClickHouse#106707 Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Enable
use_variant_as_common_typeby default, which lets you use incompatible types inside anArray, inUNIONqueries, and in branches ofif/multiIf/case.Version info
26.1.1.805