-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add patches to make passing down ClientContext optional
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
diff --git a/src/common/arrow/arrow_appender.cpp b/src/common/arrow/arrow_appender.cpp | ||
index 83f190b570..60c4b36268 100644 | ||
--- a/src/common/arrow/arrow_appender.cpp | ||
+++ b/src/common/arrow/arrow_appender.cpp | ||
@@ -40,8 +40,10 @@ void ArrowAppender::Append(DataChunk &input, const idx_t from, const idx_t to, c | ||
for (idx_t i = 0; i < input.ColumnCount(); i++) { | ||
if (root_data[i]->extension_data && root_data[i]->extension_data->duckdb_to_arrow) { | ||
Vector input_data(root_data[i]->extension_data->GetInternalType()); | ||
+ if (options.client_context) { | ||
root_data[i]->extension_data->duckdb_to_arrow(*options.client_context, input.data[i], input_data, | ||
input_size); | ||
+ } | ||
root_data[i]->append_vector(*root_data[i], input_data, from, to, input_size); | ||
} else { | ||
root_data[i]->append_vector(*root_data[i], input.data[i], from, to, input_size); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
diff --git a/src/common/arrow/arrow_converter.cpp b/src/common/arrow/arrow_converter.cpp | ||
index a693034a92..a7d4b78889 100644 | ||
--- a/src/common/arrow/arrow_converter.cpp | ||
+++ b/src/common/arrow/arrow_converter.cpp | ||
@@ -59,10 +59,10 @@ void InitializeChild(ArrowSchema &child, DuckDBArrowSchemaHolder &root_holder, c | ||
} | ||
|
||
void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, const LogicalType &type, | ||
- ClientProperties &options, ClientContext &context); | ||
+ ClientProperties &options, optional_ptr<ClientContext> context); | ||
|
||
void SetArrowMapFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, const LogicalType &type, | ||
- ClientProperties &options, ClientContext &context) { | ||
+ ClientProperties &options, optional_ptr<ClientContext> context) { | ||
child.format = "+m"; | ||
//! Map has one child which is a struct | ||
child.n_children = 1; | ||
@@ -77,18 +77,21 @@ void SetArrowMapFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, | ||
} | ||
|
||
bool SetArrowExtension(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, const LogicalType &type, | ||
- ClientContext &context) { | ||
- auto &config = DBConfig::GetConfig(context); | ||
+ optional_ptr<ClientContext> context) { | ||
+ if (!context) { | ||
+ return false; | ||
+ } | ||
+ auto &config = DBConfig::GetConfig(*context); | ||
if (config.HasArrowExtension(type.id())) { | ||
auto arrow_extension = config.GetArrowExtension(type.id()); | ||
- arrow_extension.PopulateArrowSchema(root_holder, child, type, context, arrow_extension); | ||
+ arrow_extension.PopulateArrowSchema(root_holder, child, type, *context, arrow_extension); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, const LogicalType &type, | ||
- ClientProperties &options, ClientContext &context) { | ||
+ ClientProperties &options, optional_ptr<ClientContext> context) { | ||
if (type.HasAlias()) { | ||
// If it is a json type, we only export it as json if arrow_lossless_conversion = True | ||
if (!(type.IsJSONType() && !options.arrow_lossless_conversion)) { | ||
@@ -402,7 +405,7 @@ void ArrowConverter::ToArrowSchema(ArrowSchema *out_schema, const vector<Logical | ||
root_holder->owned_column_names.push_back(AddName(names[col_idx])); | ||
auto &child = root_holder->children[col_idx]; | ||
InitializeChild(child, *root_holder, names[col_idx]); | ||
- SetArrowFormat(*root_holder, child, types[col_idx], options, *options.client_context); | ||
+ SetArrowFormat(*root_holder, child, types[col_idx], options, options.client_context); | ||
} | ||
|
||
// Release ownership to caller |