DyfanJones / RAthena

Connect R to Athena using Boto3 SDK (DBI Interface)
https://dyfanjones.github.io/RAthena/
Other
35 stars 6 forks source link

Custom escape methods for date-times #121

Closed hadley closed 4 years ago

hadley commented 4 years ago

I wasn't thinking when I merged https://github.com/tidyverse/dbplyr/pull/391 into dbplyr; the methods really should live in the individual backends. I'm going to remove these methods for the next dplyr release so can you please include in your package:

#' @export
sql_escape_date.AthenaConnection <- function(con, x) {
  paste0('date ', dbQuoteString(con, as.character(x)))
}
#' @export
sql_escape_datetime.AthenaConnection <- function(con, x) {
  x <- strftime(x, "%Y-%m-%d %H:%M:%OS %Z")
  paste0('timestamp ', dbQuoteString(con, x))
}

The code comes from OssiLehtinen so please credit him

DyfanJones commented 4 years ago

dbplyr::sql_escape_date Athena method has now been added to dev versions of RAthena and noctua. Thanks @hadley for letting me know the changes to dbplyr and thanks @OssiLehtinen for creating dbplyr::sql_escape_date Athena methods.