Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
POSIXt import to TIMESTAMP field fails #251
tbl <- bq_table( project = Sys.getenv("BIGQUERY_PROJECT"), dataset = Sys.getenv("BIGQUERY_DATASET"), table = "test_table" ) bq_table_create( tbl, fields = bq_fields( list(bq_field("datetime", "TIMESTAMP")) ) ) dt <- data.frame(datetime = Sys.time()) job <- bigrquery::bq_perform_upload( x = tbl, values = dt, write_disposition = "WRITE_APPEND", create_disposition = "CREATE_NEVER" ) bq_job_wait(job)
Hi @byapparov ,
It seems that this is because of the two lines in
If I comment these two lines out I can round trip a TIMESTAMP or a DATETIME like this:
I could make a pull request out of this but I assume that there is a good reason why these two lines are there, so I digress.
I think that I've found the good reason in that if I remove the two lines mentioned above from
I haven't been able to figure out why exactly, yet. But it seems to be something with the string representation of POSIXct values. A weird thing is, the original
This gives an error, but if one adds a second to
However the above (adding + 1 second) does not pass when the
So, no PR from me currently, as I'm not sure what's going on yet.
library(bigrquery) ds <- bq_test_dataset() df <- data.frame(datetime = as.POSIXct("2020-01-01 09:00", tz = "UTC")) tb1 <- bq_table_create( bq_table(ds, "timestamp"), bq_fields(list(bq_field("datetime", "TIMESTAMP"))) ) bq_table_upload(tb1, df) #> Error: Provided Schema does not match Table bigrquery-examples:TESTING_cpmmhddfef.timestamp. Field datetime has changed type from TIMESTAMP to INTEGER [invalid] tb2 <- bq_table_create( bq_table(ds, "datetime"), bq_fields(list(bq_field("datetime", "DATETIME"))) ) bq_table_upload(tb2, df) #> Error: Provided Schema does not match Table bigrquery-examples:TESTING_cpmmhddfef.datetime. Field datetime has changed type from DATETIME to INTEGER [invalid]
Created on 2019-01-28 by the reprex package (v0.2.1.9000)