ifNull wrapping of comparisons involving field aliases to non-nullable field types prevents the ClickHouse analyzer from being able to use the comparison expression during index selection. This causes us to read much more data than is necessary for some queries.
Problem
ifNull
wrapping of comparisons involving field aliases to non-nullable field types prevents the ClickHouse analyzer from being able to use the comparison expression during index selection. This causes us to read much more data than is necessary for some queries.See also: https://posthog.slack.com/archives/C076E99B152/p1727293461665069?thread_ts=1727254857.130799&cid=C076E99B152
Changes
Resolve field alias expressions to their actual type when determining whether or not the field is nullable.
Does this work well for both Cloud and self-hosted?
Yes.
How did you test this code?
Updated snapshots, updated tests.