Tables with date columns designated as Nullable() prompt error upon appending
Closed this issue · 4 comments
When using DBI::dbWriteTable()
where append=TRUE
and inserting into a table that has date columns that are designated as Nullable()
, the following error prompts every time:
Error in insert(conn@ptr, qname, value) :
count of elements in nested and nulls should be the same
I created 2 tables for examples by doing the following:
create table clicktest.testTable1 (`a` Nullable(String), `b` Nullable(UInt32), `c` Nullable(Date)) ENGINE=MergeTree() ORDER BY tuple()
create table clicktest.testTable2 (`a` Nullable(String), `b` Nullable(UInt32), `c` Date) ENGINE=MergeTree() ORDER BY tuple()
Which just created 2 identical tables, other than the date column being nullable on testTable1
and not testTable2
. When using RClickhouse to insert the following row:
dt = data.table(a = 'abc', b = 1, c = as.Date('2000-01-01'))
DBI::dbWriteTable(con, 'testTable1', dt, append = TRUE, overwrite = FALSE)
DBI::dbWriteTable(con, 'testTable2', dt, append = TRUE, overwrite = FALSE)
The first statement will produce the error above, meanwhile the second will insert into the table with no issues.
I forgot to mention, I experienced similar behavior when doing the same with Nullable DateTime columns.
Hi @JSchoenbachler
I am still doing some testing, but I believe to have found the reason. The NullablePtr that is pointing to the enclosing Nullable Container of the Date-Column wasn't passed to the function that turns R columns into C++ columns. Hopefully this fixes it for you.
Best regards
tridelt