v.22.9New Feature

Add INTERSECT DISTINCT and EXCEPT DISTINCT Support

Add support for INTERSECT DISTINCT and EXCEPT DISTINCT. #40792 (Duc Canh Le).
Added support for INTERSECT DISTINCT and EXCEPT DISTINCT set operations in ClickHouse.

Why it matters

This feature enables users to perform more precise set operations that eliminate duplicate rows from the results of INTERSECT and EXCEPT. It improves query correctness and aligns ClickHouse with standard SQL behavior for these operations, allowing more accurate data comparison and filtering.

How to use it

Users can use the new set operators by including INTERSECT DISTINCT or EXCEPT DISTINCT in their SQL queries similarly to other set operations. For example:

SELECT  FROM table1
INTERSECT DISTINCT
SELECT
FROM table2


This will return distinct rows present in both table1 and table2.