-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Description
BigQuery doesn't support unqualified UNION clauses:
https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#union
Everything must be UNION ALL or UNION DISTINCT (the latter being what's usually intended by UNION without ALL, but clearer to the reader).
Currently, it's not easy to make this tweak in a flavor:
Lines 671 to 684 in 5726930
| sql_query_union.DBIConnection <- function(con, x, unions, ..., lvl = 0) { | |
| methods <- ifelse(unions$all, "UNION ALL", "UNION") | |
| methods <- indent_lvl(style_kw(methods), lvl) | |
| tables <- unlist(unions$table) | |
| union_clauses <- vctrs::vec_interleave(as.character(methods), tables) | |
| out <- paste0( | |
| x, | |
| "\n\n", | |
| paste0(union_clauses, collapse = "\n\n") | |
| ) | |
| sql(out) | |
| } |
I could write my own sql_query_union() method, but that would require copy-pasting most of the logic in the default DBIConnection method.
Is the right approach to expose another method, akin to sql_join_suffix(), that returns the valid UNION operators?
sql_union_operators.DBIConnection <- function(con) c("UNION", "UNION ALL")
sql_union_operators.BigQueryConnection <- function(con) c("UNION DISTINCT", "UNION ALL")Metadata
Metadata
Assignees
Labels
No labels