-
Notifications
You must be signed in to change notification settings - Fork 183
Closed
Closed
Copy link
Description
When translating sql on a Spark SQL
connection, the 'add_year' translation is double quoting the column name:
# SQL: add_years(dob, 1)
<SQL> ADD_MONTHS('`dob`', 1.0 * 12.0)
This fails on Spark. I would expect single quotes like:
# SQL: add_years(dob, 1)
<SQL> ADD_MONTHS(`dob`, 1.0 * 12.0)
This seems to be coming from the triple-bang expression here !!!x
:
Line 47 in 8f2fcb0
sql_expr(add_months(!!!x, !!n*12)) |
add_years = function(x, n, ...) {
check_dots_empty()
sql_expr(add_months(!!!x, !!n*12))
}
There even seems to be a bad unit test for this here:
expect_equal(test_translate_sql(add_years(x, 1)), sql("ADD_MONTHS('`x`', 1.0 * 12.0)"))
If I change the triple-bang !!!x
to a double-bang !!x
:
add_years = function(x, n, ...) {
check_dots_empty()
# sql_expr(add_months(!!!x, !!n*12))
sql_expr(add_months(!!x, !!n*12))
}
it seems to produce the correct output.
Here is the reprex:
dbplyr:::local_con(dbplyr:::simulate_spark_sql())
dbplyr:::test_translate_sql(add_years(dob, 1))
#> <SQL> ADD_MONTHS('`dob`', 1.0 * 12.0)
reprex::reprex()
#> ℹ Non-interactive session, setting `html_preview = FALSE`.
#> CLIPR_ALLOW has not been set, so clipr will not run interactively
#> Error in switch(where, expr = stringify_expression(x_expr), clipboard = ingest_clipboard(), : EXPR must be a length 1 vector
ablack3
Metadata
Metadata
Assignees
Labels
No labels