v.22.7Improvement

New optimize = 1 Option in EXPLAIN AST for Rewritten AST Display

New option optimize = 1 in EXPLAIN AST. If enabled, it shows AST after it's rewritten, otherwise AST of original query. Disabled by default. #38910 (Igor Nikonov).
Added a new option optimize = 1 to the EXPLAIN AST command that shows the Abstract Syntax Tree (AST) after query rewrites instead of the original AST.

Why it matters

This feature allows users to see the optimized version of the AST after the query has been rewritten by ClickHouse. It helps in understanding how the query planner transforms the query internally, which can be valuable for debugging and query optimization.

How to use it

Use the EXPLAIN AST statement with the option optimize = 1 to display the rewritten AST. By default, this option is disabled and shows the original AST. Example:

EXPLAIN AST optimize = 1 <query>