|
| 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