Skip to content

Instantly share code, notes, and snippets.

@Ogaday
Created December 6, 2023 18:23
Show Gist options
  • Save Ogaday/86b23c378e5acfbbad7fea3e17bc3452 to your computer and use it in GitHub Desktop.
Save Ogaday/86b23c378e5acfbbad7fea3e17bc3452 to your computer and use it in GitHub Desktop.
Clickhouse - merge with nulls
/* Outer Merges with Nulls in ClickHouse
*
* By default, outer merges in clickhouse will produce _interesting_ defualt
* values for empty cells in an outer join. This query demonstrates how to
* configure clickhouse to use nulls for missing values, as in the SQL
* standard.
*
* See: https://clickhouse.com/docs/en/operations/settings/settings#join_use_nulls
*
*/
SELECT
*
FROM left
FULL OUTER JOIN right
ON left.key = right.key
ORDER BY COALESE(left.value, right.value)
SETTINGS join_use_nulls=1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment