tobymao / sqlglot

Python SQL Parser and Transpiler
https://sqlglot.com/
MIT License
5.79k stars 582 forks source link

bigquery dialect converting UNION to UNION DISTINCT #3479

Closed sumeet-wisdom closed 2 weeks ago

sumeet-wisdom commented 2 weeks ago
query = "select * from table2 union select * from table3"
sql_tree = parse_one(query, dialect="bigquery")
print(sql_tree.sql(dialect="bigquery"))

This adds a DISTINCT keyword SELECT * FROM table2 UNION DISTINCT SELECT * FROM table3.

tobymao commented 2 weeks ago

i believe these are equivalent,

union all vs union distinct