From 5934ad00aa394fe9032a6bbd1c1493a23f4bbc75 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sat, 28 Sep 2024 11:12:41 -0400 Subject: [PATCH] [r] Make `DataFrame` objects shapeable at ingest --- apis/r/R/write_soma.R | 18 ++++++++++++++++++ apis/r/tests/testthat/test-write-soma-resume.R | 1 + 2 files changed, 19 insertions(+) diff --git a/apis/r/R/write_soma.R b/apis/r/R/write_soma.R index e1433458d6..b886efa781 100644 --- a/apis/r/R/write_soma.R +++ b/apis/r/R/write_soma.R @@ -219,12 +219,30 @@ write_soma.data.frame <- function( choices = names(x), several.ok = TRUE ) + + # For index_column_name being soma_joinid -- this being the default + # -- set that domain slot to match the date. This will endow the + # dataframe with something users think of as a "shape". For the + # other slots, set the domain wide open. + # + # TODO: do this only if the new-shape feature flag is enabled. + domain <- list() + for (index_column_name in index_column_names) { + if (index_column_name == "soma_joinid") { + domain[["soma_joinid"]] <- c(0, nrow(x) - 1) + } else { + domain[[index_column_name]] <- NULL + } + } + # Create the SOMADataFrame tbl <- arrow::arrow_table(x) sdf <- SOMADataFrameCreate( uri = uri, schema = tbl$schema, index_column_names = index_column_names, + # XXX TEMP + domain = domain, ingest_mode = ingest_mode, platform_config = platform_config, tiledbsoma_ctx = tiledbsoma_ctx diff --git a/apis/r/tests/testthat/test-write-soma-resume.R b/apis/r/tests/testthat/test-write-soma-resume.R index 4a2aaf517c..7b55a5449a 100644 --- a/apis/r/tests/testthat/test-write-soma-resume.R +++ b/apis/r/tests/testthat/test-write-soma-resume.R @@ -164,6 +164,7 @@ test_that("Resume-mode data frames", { } } + # TODO: resize if new shape feature-flag is enabled expect_s3_class( sdfc <- write_soma( co2,