add dplyr translation support for TIMESTAMP_TRUNC
The dplyr translation does not currently support the floor_date() function. Should it be mapped to the TIMESTAMP_TRUNC sql statement? The POSIXt objects are mapped to TIMESTAMP and not DATETIME so I think TIMESTAMP_TRUNC is best.
This is derived from dbplyr's translation for Postgres.
floor_date = function(x, unit = "seconds") {
unit <- arg_match(unit,
c("second", "minute", "hour", "day", "week", "month", "quarter", "year")
)
sql_expr(TIMESTAMP_TRUNC(!!unit, !!x))
},
I'm not sure how it would handle the translation of the timezone argument to TIMESTAMP_TRUNC because floor_date() does not support a timezone argument.
Good idea!
Docs here: https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#timestamp_trunc
Will wait on https://github.com/tidyverse/dbplyr/pull/1357 and tackle a swathe of date functions all at once.