Skip to content

Commit

Permalink
Ensure DATETIME columns get Arrow coltype reset
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Mar 20, 2024
1 parent 3a88e6c commit a73b741
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libtiledbsoma/src/utils/arrow_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ ArrowAdapter::to_arrow(std::shared_ptr<ColumnBuffer> column) {
exitIfError(ArrowArrayAllocateChildren(arr, 0), "Bad array children alloc");
array->length = column->size();

Check warning on line 315 in libtiledbsoma/src/utils/arrow_adapter.cc

View check run for this annotation

Codecov / codecov/patch

libtiledbsoma/src/utils/arrow_adapter.cc#L313-L315

Added lines #L313 - L315 were not covered by tests

LOG_TRACE(fmt::format(
LOG_WARN(fmt::format(
"[ArrowAdapter] column type {} name {} nbuf {} {} nullable {}",
to_arrow_format(column->type()).data(), column->name().data(), n_buffers,
array->n_buffers, column->is_nullable()));

Check warning on line 320 in libtiledbsoma/src/utils/arrow_adapter.cc

View check run for this annotation

Codecov / codecov/patch

libtiledbsoma/src/utils/arrow_adapter.cc#L317-L320

Added lines #L317 - L320 were not covered by tests
Expand Down Expand Up @@ -359,8 +359,16 @@ ArrowAdapter::to_arrow(std::shared_ptr<ColumnBuffer> column) {
column->data_to_bitmap();

Check warning on line 359 in libtiledbsoma/src/utils/arrow_adapter.cc

View check run for this annotation

Codecov / codecov/patch

libtiledbsoma/src/utils/arrow_adapter.cc#L359

Added line #L359 was not covered by tests
}

// Workaround for datetime
if (column->type() == TILEDB_DATETIME_MS || column->type() == TILEDB_DATETIME_SEC) {
free((void*)schema->format); // free the 'storage' format
schema->format = strdup(to_arrow_format(column->type()).data());

Check warning on line 365 in libtiledbsoma/src/utils/arrow_adapter.cc

View check run for this annotation

Codecov / codecov/patch

libtiledbsoma/src/utils/arrow_adapter.cc#L364-L365

Added lines #L364 - L365 were not covered by tests
}

// Workaround for date
if (column->type() == TILEDB_DATETIME_DAY) {
free((void*)schema->format); // free the 'storage' format
schema->format = strdup(to_arrow_format(column->type()).data());

Check warning on line 371 in libtiledbsoma/src/utils/arrow_adapter.cc

View check run for this annotation

Codecov / codecov/patch

libtiledbsoma/src/utils/arrow_adapter.cc#L370-L371

Added lines #L370 - L371 were not covered by tests
// TODO: Put in ColumnBuffer
size_t n = array->length;
std::vector<int64_t> indata(n);
Expand Down

0 comments on commit a73b741

Please sign in to comment.