v.20.4Improvement

Set Multiple JOINs Rewrite Version 2 Enhances Column Handling and Subquery Support

If set multiple_joins_rewriter_version = 2 enables second version of multiple JOIN rewrites that keeps not clashed column names as is. It supports multiple JOINs with USING and allow select * for JOINs with subqueries. #9739 (Artem Zuikov)
Enables the second version of the multiple JOINs rewriter in ClickHouse, which preserves non-clashing column names and supports multiple JOINs using USING, allowing SELECT * for JOINs involving subqueries.

Why it matters

This feature improves the handling of multiple JOINs by preventing unnecessary column name clashes and enabling more flexible queries with subqueries. It enhances query readability and usability by allowing simpler syntax with SELECT * in complex JOIN scenarios.

How to use it

Enable the feature by setting the session or query parameter multiple_joins_rewriter_version = 2. For example:

SET multiple_joins_rewriter_version = 2;


Then proceed to write queries with multiple JOINs using USING and SELECT * as needed.