I'm attempting to add an entry to a Postgres table where one of the columns is an interval. However, I'm unsure how to cast a local tibble's column type as an interval. As you might imagine, type differences make for unhappy databases. Any way to resolve this?
library(dbplyr)
library(dplyr)
con <- my_db_con
df1 <- tibble(my_interval = "P3D")
df2 <- tbl(con, sql("select 'P3D'::interval as my_interval"))
# Will error:
rows_upsert(df2, df1, copy = TRUE)
The resultant error:
Matching, by = "my_interval"
Error: Failed to prepare query: ERROR: operator does not exist: text = interval
LINE 9: WHERE ("LHS"."my_interval" = "RHS"."my_interval")
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
Thank you for your time.