Skip to content

Commit

Permalink
fix: add support for union by name (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
tconbeer authored Jul 25, 2024
1 parent adfb114 commit b39751c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Formatting Changes and Bug Fixes

- DuckDB's `union [all] by name` is now supported ([#611](https://github.com/tconbeer/sqlfmt/issues/611) - thank you [@aersam](https://github.com/aersam)!).

## [0.21.4] - 2024-07-09

### Formatting Changes and Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
name="set_operator",
priority=1320,
pattern=group(
r"(union|intersect|except|minus)(\s+(all|distinct))?",
r"(union|intersect|except|minus)(\s+(all|distinct))?(\s+by\s+name)?",
)
+ group(r"\W", r"$"),
action=actions.handle_set_operator,
Expand Down
2 changes: 2 additions & 0 deletions tests/unit_tests/test_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ def get_rule(ruleset: List[Rule], rule_name: str) -> Rule:
(MAIN, "set_operator", "union"),
(MAIN, "set_operator", "union all"),
(MAIN, "set_operator", "union distinct"),
(MAIN, "set_operator", "union by name"),
(MAIN, "set_operator", "union all by name"),
(MAIN, "set_operator", "intersect"),
(MAIN, "set_operator", "minus"),
(MAIN, "set_operator", "except"),
Expand Down

0 comments on commit b39751c

Please sign in to comment.