Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PostgreSQL set operation precedence #3567

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions sql/postgresql/PostgreSQLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -2902,33 +2902,25 @@ select_no_parens
;

select_clause
: simple_select
| select_with_parens
: simple_select_intersect ((UNION | EXCEPT) all_or_distinct simple_select_intersect)*
;

simple_select
simple_select_intersect
: simple_select_pramary ((INTERSECT) all_or_distinct simple_select_pramary)*
tisonkun marked this conversation as resolved.
Show resolved Hide resolved
;

simple_select_pramary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simple_select_"pramary" ? Do you mean "primary" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a typo 🤣

: ( SELECT (opt_all_clause into_clause opt_target_list | distinct_clause target_list)
into_clause
from_clause
where_clause
group_clause
having_clause
window_clause
| values_clause
| TABLE relation_expr
| select_with_parens set_operator_with_all_or_distinct (simple_select | select_with_parens)
)
(set_operator_with_all_or_distinct (simple_select | select_with_parens))*
;

set_operator
: UNION # union
| INTERSECT # intersect
| EXCEPT # except
;

set_operator_with_all_or_distinct
: set_operator all_or_distinct
)
| values_clause
| TABLE relation_expr
| select_with_parens
;

with_clause
Expand Down
Loading