v.22.8Improvement

Normalize AggregateFunction Types and State Representations for Optimization Compatibility

Normalize AggregateFunction types and state representations because optimizations like #35788 will treat count(not null columns) as count(), which might confuses distributed interpreters with the following error : Conversion from AggregateFunction(count) to AggregateFunction(count, Int64) is not supported. #39420 (Amos Bird). The functions with identical states can be used in materialized views interchangeably.
Normalize AggregateFunction types and their state representations to ensure consistent behavior during optimizations and prevent type conversion errors.

Why it matters

This feature addresses issues where optimizations such as treating count(not null columns) as count() caused errors in distributed query interpreters, like the error Conversion from AggregateFunction(count) to AggregateFunction(count, Int64) is not supported. By normalizing the AggregateFunction types and states, it ensures compatibility and interchangeability of functions with identical states, especially useful for materialized views.

How to use it

No explicit user action is required. The normalization is applied internally to AggregateFunction types and state representations, allowing users to freely use aggregate functions with identical states in materialized views and distributed queries without encountering conversion errors.