Incorrect formatting of dates
Closed this issue · 1 comments
abhinavjindal commented
Hey guys,
I am having an issue with reading tables that contain a Date type column. The date column appears to have a weird format when read into R, even though the dates are written properly on clickhouse when tested via clickhouse-client on the terminal.
Please take a look at this example:
library(RClickhouse)
library(DBI)
drv = RClickhouse::clickhouse()
conn = dbConnect(drv, host="localhost", port=9000, user="abhi", password="RBgCR9YS")
dbListTables(conn)
dbSendQuery(conn, "create database test_db")
dbDisconnect(conn)
conn = dbConnect(drv, db = "test_db", host="localhost", port=9000, user="default", password="")
data = data.frame(
date = seq(as.Date('2017-01-01'), as.Date('2017-12-31'), by = 1),
value = 1:365
)
dbWriteTable(conn, "test_tbl", data, append = TRUE, overwrite = FALSE)
dbGetQuery(conn, "describe table test_tbl")
ret_data = dbGetQuery(conn, "select * from test_tbl")
head(ret_data)
date value
1 4062912-07-11 1
2 4063149-01-30 2
3 4063385-08-20 3
4 4063622-03-11 4
5 4063858-09-30 5
6 4064095-04-20 6
As you can see the dates are in a non-sensical format. Is this a bug of some sort?
This issue has existed even in the clckhs package since the changes committed in October.
v5r commented
Hi,
yes, that's definitely a bug, I'll look into it. Thanks for letting us know!