Skip to content

Commit

Permalink
Adapt to changes connected to Arrow extension_types
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopi committed Jan 16, 2025
1 parent 03041a6 commit b315e18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/src/webdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ arrow::Result<std::shared_ptr<arrow::Buffer>> WebDB::Connection::MaterializeQuer
// Configure the output writer
ArrowSchema raw_schema;
ClientProperties options;
unordered_map<idx_t, const shared_ptr<ArrowTypeExtensionData>> extension_type_cast;
options.arrow_offset_size = ArrowOffsetSize::REGULAR;
ArrowConverter::ToArrowSchema(&raw_schema, result->types, result->names, options);
ARROW_ASSIGN_OR_RAISE(auto schema, arrow::ImportSchema(&raw_schema));
Expand All @@ -118,7 +119,7 @@ arrow::Result<std::shared_ptr<arrow::Buffer>> WebDB::Connection::MaterializeQuer
for (auto chunk = result->Fetch(); !!chunk && chunk->size() > 0; chunk = result->Fetch()) {
// Import the data chunk as record batch
ArrowArray array;
ArrowConverter::ToArrowArray(*chunk, &array, options);
ArrowConverter::ToArrowArray(*chunk, &array, options, extension_type_cast);
// Import the record batch
ARROW_ASSIGN_OR_RAISE(auto batch, arrow::ImportRecordBatch(&array, schema));
// Patch the record batch
Expand Down Expand Up @@ -251,8 +252,9 @@ arrow::Result<std::shared_ptr<arrow::Buffer>> WebDB::Connection::FetchQueryResul
// Serialize the record batch
ArrowArray array;
ClientProperties arrow_options;
unordered_map<idx_t, const shared_ptr<ArrowTypeExtensionData>> extension_type_cast;
arrow_options.arrow_offset_size = ArrowOffsetSize::REGULAR;
ArrowConverter::ToArrowArray(*chunk, &array, arrow_options);
ArrowConverter::ToArrowArray(*chunk, &array, arrow_options, extension_type_cast);
ARROW_ASSIGN_OR_RAISE(auto batch, arrow::ImportRecordBatch(&array, current_schema_));
// Patch the record batch
ARROW_ASSIGN_OR_RAISE(batch, patchRecordBatch(batch, current_schema_patched_, webdb_.config_->query));
Expand Down
12 changes: 12 additions & 0 deletions patches/duckdb/add_constructor_client_properties.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/include/duckdb/main/client_properties.hpp b/src/include/duckdb/main/client_properties.hpp
index a4038a7353..d3a269ea36 100644
--- a/src/include/duckdb/main/client_properties.hpp
+++ b/src/include/duckdb/main/client_properties.hpp
@@ -26,6 +26,7 @@ struct ClientProperties {
arrow_use_list_view(arrow_use_list_view_p), produce_arrow_string_view(produce_arrow_string_view_p),
arrow_lossless_conversion(lossless_conversion), client_context(client_context) {
}
+ ClientProperties() {}

string time_zone = "UTC";
ArrowOffsetSize arrow_offset_size = ArrowOffsetSize::REGULAR;

0 comments on commit b315e18

Please sign in to comment.