diff --git a/CHANGELOG.md b/CHANGELOG.md index bc8873f..a76954a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Formatting Changes and Bug Fixes + +- sqlfmt now lexes ClickHouse `any left join` as a join keyword; in 0.28.0 we only supported the other syntax, `left any join` ([#719](https://github.com/tconbeer/sqlfmt/issues/719) - thank you [@haild-metricvn](https://github.com/haild-metricvn); see also [#713](https://github.com/tconbeer/sqlfmt/pull/713)). + ## [0.28.1] - 2025-10-22 ### Formatting Changes and Bug Fixes diff --git a/src/sqlfmt/rules/__init__.py b/src/sqlfmt/rules/__init__.py index e1a1069..a5c9ac1 100644 --- a/src/sqlfmt/rules/__init__.py +++ b/src/sqlfmt/rules/__init__.py @@ -82,7 +82,7 @@ r"delete\s+from", r"from", ( - r"((global|natural|asof)\s+)?" + r"((global|natural|asof|any)\s+)?" r"((inner|left|right|full|cross)\s+)?" r"((outer|semi|anti|any|all|asof|cross|positional|array|paste)\s+)?join" ), diff --git a/tests/data/unformatted/220_clickhouse_joins.sql b/tests/data/unformatted/220_clickhouse_joins.sql index bdc22cb..3c5797e 100644 --- a/tests/data/unformatted/220_clickhouse_joins.sql +++ b/tests/data/unformatted/220_clickhouse_joins.sql @@ -43,7 +43,7 @@ FROM count() AS hits FROM test.hits GROUP BY CounterID -) LEFT ANY JOIN +) ANY LEFT JOIN ( SELECT CounterID, @@ -89,7 +89,7 @@ where select counterid, hits, visits from (select counterid, count() as hits from test.hits group by counterid) -left any join +any left join (select counterid, sum(sign) as visits from test.visits group by counterid) using counterid order by hits desc diff --git a/tests/unit_tests/test_rule.py b/tests/unit_tests/test_rule.py index 8380e26..b0ac458 100644 --- a/tests/unit_tests/test_rule.py +++ b/tests/unit_tests/test_rule.py @@ -208,6 +208,7 @@ def get_rule(ruleset: List[Rule], rule_name: str) -> Rule: (MAIN, "unterm_keyword", "anti join"), (MAIN, "unterm_keyword", "any join"), (MAIN, "unterm_keyword", "left any join"), + (MAIN, "unterm_keyword", "any left join"), (MAIN, "unterm_keyword", "all join"), (MAIN, "unterm_keyword", "array join"), (MAIN, "unterm_keyword", "left array join"),