v.25.5New Feature

Support scalar correlated subqueries

Support scalar correlated subqueries in the WHERE clause. Closes #6697. #79600 (Dmitry Novik). Support correlated subqueries in the projection list in simple cases. #79925 (Dmitry Novik). #76078 (Dmitry Novik). Now it covers 100% of TPC-H test suite.
Support for scalar correlated subqueries in the WHERE clause and simple correlated subqueries in the projection list, ensuring full compliance with the TPC-H test suite.

Why it matters

This feature enables ClickHouse to handle scalar correlated subqueries, which are subqueries that reference columns from outer queries, improving query expressiveness and compatibility with complex SQL patterns. It resolves previous limitations by allowing users to write more advanced filtering and projection logic, enhancing query flexibility and supporting a wider range of analytical workloads.

How to use it

Users can now write scalar correlated subqueries directly within the WHERE clause or in the projection list in simple cases without any special configuration. Example usage in the WHERE clause:

SELECT ...
FROM ...
WHERE column = (SELECT scalar_value FROM ... WHERE outer_table.column = inner_table.column)


No additional settings are required to enable this feature.