Skip to content

Commit 5cdd2fe

Browse files
committed
Add patches to make passing down ClientContext optional
1 parent b315e18 commit 5cdd2fe

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/src/common/arrow/arrow_appender.cpp b/src/common/arrow/arrow_appender.cpp
2+
index 83f190b570..60c4b36268 100644
3+
--- a/src/common/arrow/arrow_appender.cpp
4+
+++ b/src/common/arrow/arrow_appender.cpp
5+
@@ -40,8 +40,10 @@ void ArrowAppender::Append(DataChunk &input, const idx_t from, const idx_t to, c
6+
for (idx_t i = 0; i < input.ColumnCount(); i++) {
7+
if (root_data[i]->extension_data && root_data[i]->extension_data->duckdb_to_arrow) {
8+
Vector input_data(root_data[i]->extension_data->GetInternalType());
9+
+ if (options.client_context) {
10+
root_data[i]->extension_data->duckdb_to_arrow(*options.client_context, input.data[i], input_data,
11+
input_size);
12+
+ }
13+
root_data[i]->append_vector(*root_data[i], input_data, from, to, input_size);
14+
} else {
15+
root_data[i]->append_vector(*root_data[i], input.data[i], from, to, input_size);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
diff --git a/src/common/arrow/arrow_converter.cpp b/src/common/arrow/arrow_converter.cpp
2+
index a693034a92..a7d4b78889 100644
3+
--- a/src/common/arrow/arrow_converter.cpp
4+
+++ b/src/common/arrow/arrow_converter.cpp
5+
@@ -59,10 +59,10 @@ void InitializeChild(ArrowSchema &child, DuckDBArrowSchemaHolder &root_holder, c
6+
}
7+
8+
void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, const LogicalType &type,
9+
- ClientProperties &options, ClientContext &context);
10+
+ ClientProperties &options, optional_ptr<ClientContext> context);
11+
12+
void SetArrowMapFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, const LogicalType &type,
13+
- ClientProperties &options, ClientContext &context) {
14+
+ ClientProperties &options, optional_ptr<ClientContext> context) {
15+
child.format = "+m";
16+
//! Map has one child which is a struct
17+
child.n_children = 1;
18+
@@ -77,18 +77,21 @@ void SetArrowMapFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child,
19+
}
20+
21+
bool SetArrowExtension(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, const LogicalType &type,
22+
- ClientContext &context) {
23+
- auto &config = DBConfig::GetConfig(context);
24+
+ optional_ptr<ClientContext> context) {
25+
+ if (!context) {
26+
+ return false;
27+
+ }
28+
+ auto &config = DBConfig::GetConfig(*context);
29+
if (config.HasArrowExtension(type.id())) {
30+
auto arrow_extension = config.GetArrowExtension(type.id());
31+
- arrow_extension.PopulateArrowSchema(root_holder, child, type, context, arrow_extension);
32+
+ arrow_extension.PopulateArrowSchema(root_holder, child, type, *context, arrow_extension);
33+
return true;
34+
}
35+
return false;
36+
}
37+
38+
void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, const LogicalType &type,
39+
- ClientProperties &options, ClientContext &context) {
40+
+ ClientProperties &options, optional_ptr<ClientContext> context) {
41+
if (type.HasAlias()) {
42+
// If it is a json type, we only export it as json if arrow_lossless_conversion = True
43+
if (!(type.IsJSONType() && !options.arrow_lossless_conversion)) {
44+
@@ -402,7 +405,7 @@ void ArrowConverter::ToArrowSchema(ArrowSchema *out_schema, const vector<Logical
45+
root_holder->owned_column_names.push_back(AddName(names[col_idx]));
46+
auto &child = root_holder->children[col_idx];
47+
InitializeChild(child, *root_holder, names[col_idx]);
48+
- SetArrowFormat(*root_holder, child, types[col_idx], options, *options.client_context);
49+
+ SetArrowFormat(*root_holder, child, types[col_idx], options, options.client_context);
50+
}
51+
52+
// Release ownership to caller

0 commit comments

Comments
 (0)