Skip to content

parsing bug with intersect, dialect: postgres #8390

Description

@laravioli

postgres: there is a bug while parsing a chain of union/intersect

postgres doc (18.6) state:

without parentheses,
UNION and EXCEPT associate left-to-right, but INTERSECT binds more tightly than those two
operators. Thus
query1 UNION query2 INTERSECT query3
means
query1 UNION (query2 INTERSECT query3)

from sqlglot import parse_one
select = """select 1 union select 2 intersect select 3"""
parse_one(select, dialect= "postgres")

show -> (query1 UNION query2) INTERSECT query3
instead of -> query1 UNION (query2 INTERSECT query3)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions