Skip to content

Commit

Permalink
Merge pull request #105 from Altinity/ashwini-ahire7-patch-2
Browse files Browse the repository at this point in the history
Update ansi-sql-mode.md
  • Loading branch information
den-crane authored Sep 19, 2024
2 parents d5c8ba4 + d1b164c commit 9dee956
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions content/en/altinity-kb-queries-and-syntax/ansi-sql-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,49 @@ linkTitle: "ANSI SQL mode"
description: >
ANSI SQL mode
---
It's possible to tune some settings which would make ClickHouse® more ANSI SQL compatible(and slower):
To make ClickHouse® more compatible with ANSI SQL standards (at the expense of some performance), you can adjust several settings. These configurations will bring ClickHouse closer to ANSI SQL behavior but may introduce a slowdown in query performance:

```sql
SET join_use_nulls=1; -- introduced long ago
SET cast_keep_nullable=1; -- introduced in 20.5
SET union_default_mode='DISTINCT'; -- introduced in 21.1
SET allow_experimental_window_functions=1; -- introduced in 21.3
SET prefer_column_name_to_alias=1; -- introduced in 21.4;
SET group_by_use_nulls=1; -- introduced in 22.7;
join_use_nulls=1
```
Introduced in: early versions
Ensures that JOIN operations return NULL for non-matching rows, aligning with standard SQL behavior.


```sql
cast_keep_nullable=1
```
Introduced in: v20.5
Preserves the NULL flag when casting between data types, which is typical in ANSI SQL.


```sql
union_default_mode='DISTINCT'
```
Introduced in: v21.1
Makes the UNION operation default to UNION DISTINCT, which removes duplicate rows, following ANSI SQL behavior.


```sql
allow_experimental_window_functions=1
```
Introduced in: v21.3
Enables support for window functions, which are a standard feature in ANSI SQL.


```sql
prefer_column_name_to_alias=1
```
Introduced in: v21.4
This setting resolves ambiguities by preferring column names over aliases, following ANSI SQL conventions.


```sql
group_by_use_nulls=1
```
Introduced in: v22.7
Allows NULL values to appear in the GROUP BY clause, consistent with ANSI SQL behavior.

By enabling these settings, ClickHouse becomes more ANSI SQL-compliant, although this may come with a trade-off in terms of performance. Each of these options can be enabled as needed, based on the specific SQL compatibility requirements of your application.


0 comments on commit 9dee956

Please sign in to comment.