From bed7757f913ba613848f8f7e34da0171d8eb6d28 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Wed, 27 Mar 2024 07:35:46 -0500 Subject: [PATCH] Post-rebase change --- libtiledbsoma/src/utils/arrow_adapter.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libtiledbsoma/src/utils/arrow_adapter.cc b/libtiledbsoma/src/utils/arrow_adapter.cc index c79c3bb652..39034e745e 100644 --- a/libtiledbsoma/src/utils/arrow_adapter.cc +++ b/libtiledbsoma/src/utils/arrow_adapter.cc @@ -191,6 +191,13 @@ std::unique_ptr ArrowAdapter::arrow_schema_from_tiledb_array( auto dict = (ArrowSchema *)malloc(sizeof(ArrowSchema)); dict->format = strdup(ArrowAdapter::to_arrow_format(enmr.type(), false).data()); + if (enmr.type() == TILEDB_STRING_ASCII or + enmr.type() == TILEDB_CHAR) { + dict->format = strdup("z"); + } else { + dict->format = strdup( + ArrowAdapter::to_arrow_format(enmr.type(), false).data()); + } dict->name = strdup(enmr.name().c_str()); dict->metadata = nullptr; dict->flags = 0; @@ -409,7 +416,7 @@ ArrowAdapter::to_arrow(std::shared_ptr column) { exitIfError(ArrowArrayInitFromType(dict_arr, dnatype), "Bad array init"); exitIfError(ArrowArrayAllocateChildren(dict_arr, 0), "Bad array children alloc"); - const int n_buf = strcmp(dict_sch->format, "u") == 0 ? 3 : 2; + const int n_buf = ArrowAdapter::_isstr(dict_sch->format) == 0 ? 3 : 2; dict_arr->buffers = (const void **)malloc(sizeof(void *) * n_buf); dict_arr->buffers[0] = nullptr; // validity: none here dict_arr->release = &release_array; @@ -424,7 +431,8 @@ ArrowAdapter::to_arrow(std::shared_ptr column) { // returns std::optional where std::nullopt indicates the // column does not contain enumerated values. if (enmr->type() == TILEDB_STRING_ASCII or - enmr->type() == TILEDB_STRING_UTF8) { + enmr->type() == TILEDB_STRING_UTF8 or + enmr->type() == TILEDB_CHAR) { auto dict_vec = enmr->as_vector(); column->convert_enumeration(); dict_arr->buffers[1] = column->enum_offsets().data();