KxSystems / rkdb

R client for kdb+
https://code.kx.com/q/interfaces
Apache License 2.0
41 stars 30 forks source link

Bug when passing trivial data.frame frm R -> kdb #58

Closed statquant closed 4 years ago

statquant commented 4 years ago

Hello I do not understand why the basic example bellow is failing

R> dput(DF2)
structure(list(date = structure(c(17897L, 17897L), class = "Date"), 
    sym = c("AAAA.L", "AAL.L"), delta_usd = c(-144930.612769693, 
    -152637.728273474), weight = c(31472.1659906769, 1e+06)), .Names = c("date",
"sym", "delta_usd", "weight"), row.names = 1:2, class = "data.frame")
R> dput(DF)
structure(list(x = c(1, 1), y = c(2, 2), sym = c("AAA.L", "AAA.L"
), date = structure(c(17897, 17897), class = "Date")), .Names = c("x", 
"y", "sym", "date"), row.names = c("1", "1.1"), class = "data.frame")
R>  execute(con, "meta", DF)
     c t f a
1    x f    
2    y f    
3  sym C    
4 date d    
R>  execute(con, "meta", DF2)
Error in execute(con, "meta", DF2) : 
  REAL() can only be applied to a 'numeric', not a 'integer'
statquant commented 4 years ago

So the issue appear to be that in DF2 the Date column is using integer (17897L) as underlying data whereas for DF it is using numeric (17897). Would you kindly fix this in the C code (probably casting to integer would be fine)