ClickHouse / ClickHouse/ClickHouse
Aggregate function states lose Nullable type after adding -If suffix
- Dominant language
- C++
- Stars
- 49.9k
- Forks
- 9k
- Avg merge
- 21h 32m
- Merged PRs (30d)
- 515
Description
Hello, I was trying to combine different aggregate function states inside multiIf and got an error like:
```
DB::Exception: There is no supertype for types AggregateFunction(quantile, Nullable(Float64)), AggregateFunction(quantile, Nullable(Float64)), AggregateFunction(quantile, Float64)
```
I found out that **_-If_** combinator can somehow change argument type of aggregate function state like so:
```sql
WITH arrayJoin([1.5, 2, 2.5, NULL]) AS test_data
SELECT
toTypeName(medianState(test_data)) AS median_state_type,
toTypeName(medianStateIf(test_data, 1)) AS median_state_if_type
FORMAT Vertical
Query id: cb0b607f-5518-4e18-872a-3f041dbb444b
Row 1:
──────
median_state_type: AggregateFunction(quantile, Nullable(Float64))
median_state_if_type: AggregateFunction(quantile, Float64)
1 row in set. Elapsed: 0.001 sec.
```
The result with **_-If_** suffix is not Nullable anymore. Is it a supposed behaviour or not? Is there any possible workaround to get compatible states in this case?
Can be reproduced on Clickhouse 23.11.3.23 and many other versions (including latest) on https://fiddle.clickhouse.com/.
Contributor guide
Assessment
This issue has not been assessed yet.