-
Notifications
You must be signed in to change notification settings - Fork 182
Description
I want to add a translation for .POSIXct()
--> TIMESTAMP_FROM_UNIX_SECONDS()
:
https://cloud.google.com/dataflow/docs/reference/sql/timestamp_functions#timestamp_from_unix_seconds
However, the leading .
appears to be throwing everything off. I added a simple placeholder translation in this branch:
https://github.com/MichaelChirico/dbplyr/tree/leading-dot
.POSIXct = sql_prefix("foo", 1)
With that, I get a failed translation:
library(dbplyr)
con=simulate_dbi()
translate_sql(.POSIXct(0), con=con)
# <SQL> .POSIXct(0.0)
(should be foo()
)
I looked into this a bit and I got lost in the details of the implementation. sql_variant()
seems to be doing just fine, as base_scalar
does contain the correct object still:
evalq(exists(".POSIXct", base_scalar), asNamespace("dbplyr"))
# [1] TRUE
However, this step apparently fails to find the correct translation:
Lines 148 to 149 in 860bd6a
mask <- sql_data_mask(x, variant, con = con, window = window) | |
escape(eval_tidy(x, mask), con = con) |
I am not familiar enough with the details of tidy eval to know if there's an easy fix.