-
-
Save johnkerl/21eee1ef55a9ad1ecac8a4aa3049e5f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
library(tiledbsoma) | |
uri <- 'tiledbsoma-write-nulls' | |
unlink(uri, recursive=TRUE) | |
schema = arrow::schema( | |
#arrow::field("soma_joinid", arrow::int64(), nullable = FALSE), | |
#arrow::field("mystring", arrow::large_utf8(), nullable = FALSE), | |
#arrow::field("myint", arrow::float64(), nullable = FALSE) | |
# Arrow seems to make this nullable = TRUE by default | |
arrow::field("soma_joinid", arrow::int64()), | |
arrow::field("mystring", arrow::large_utf8()), | |
arrow::field("myenum", arrow::dictionary(index_type = arrow::int8(), value_type = arrow::utf8())), | |
arrow::field("myint", arrow::int32()), | |
arrow::field("myfloat", arrow::float64()), | |
) | |
tbl <- arrow::arrow_table( | |
soma_joinid = bit64::as.integer64(c(0,1,2,3,4,5)), | |
mystring = c('a', 'b', NA, 'd', 'e', 'f'), | |
myenum = factor(c("B cell", NA, "T cell", "B cell", "T cell", NA)), | |
myint = c(10,20,30,NA,50,60), | |
myfloat = c(10,20,30,NA,50,60), | |
schema=schema | |
) | |
sdf <- SOMADataFrameCreate(uri, schema) | |
sdf$write(tbl) | |
sdf$close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment