v.20.1New Feature

Add SEMI and ANTI JOINs; rename ANY INNER JOIN to SEMI LEFT JOIN

Add new SEMI and ANTI JOIN. Old ANY INNER JOIN behaviour now available as SEMI LEFT JOIN. #7665 (Artem Zuikov)
Introduces new SEMI JOIN and ANTI JOIN types in ClickHouse, with the former replacing the previous ANY INNER JOIN behavior now accessible as SEMI LEFT JOIN.

Why it matters

This feature clarifies and extends join semantics in ClickHouse by explicitly supporting semi and anti joins. It addresses the need for more precise control over join behaviors, enabling users to perform existence checks (SEMI JOIN) and non-existence checks (ANTI JOIN) more intuitively and efficiently.

How to use it

Users can use SEMI JOIN and ANTI JOIN explicitly in their SQL queries to perform semi and anti joins respectively. The previously used ANY INNER JOIN syntax is now replaced by SEMI LEFT JOIN for backwards compatibility and clearer semantics. For example:

SELECT  FROM table1 <code>SEMI JOIN</code> table2 ON table1.key = table2.key;


SELECT  FROM table1 <code>ANTI JOIN</code> table2 ON table1.key = table2.key;