v.23.7Improvement

Convert toyear Condition to Range Format

Convert condition like toyear(x) = c to c1 <= x < c2. #51795 (Han Fei).
Convert conditions of the form toYear(x) = c into equivalent range conditions c1 <= x < c2 for improved query optimization.

Why it matters

This feature improves query performance by rewriting expressions that compare the year part of a date or date-time column to a constant into a range condition on the original column. This allows the query planner to apply more efficient filtering and indexing strategies.

How to use it

Users do not need to change their query syntax. The ClickHouse engine automatically converts conditions like toYear(x) = c into range predicates c1 <= x < c2 during query analysis, enhancing optimization.