@@ -94,12 +94,12 @@ struct GdalScanFunctionData : public TableFunctionData {
94
94
vector<string> layer_creation_options;
95
95
unique_ptr<SpatialFilter> spatial_filter;
96
96
GDALDatasetUniquePtr dataset;
97
- unordered_map<idx_t , unique_ptr<ArrowConvertData>> arrow_convert_data;
98
97
idx_t max_threads;
99
98
// before they are renamed
100
99
vector<string> all_names;
101
100
vector<LogicalType> all_types;
102
101
atomic<idx_t > lines_read;
102
+ ArrowTableType arrow_table;
103
103
};
104
104
105
105
struct GdalScanLocalState : ArrowScanLocalState {
@@ -351,16 +351,19 @@ unique_ptr<FunctionData> GdalTableFunction::Bind(ClientContext &context, TableFu
351
351
' :' , ' e' , ' x' , ' t' , ' e' , ' n' , ' s' , ' i' , ' o' , ' n' , ' :' , ' n' , ' a' ,
352
352
' m' , ' e' , ' \a ' , ' \0 ' , ' \0 ' , ' \0 ' , ' o' , ' g' , ' c' , ' .' , ' w' , ' k' , ' b' };
353
353
354
+ auto arrow_type = GetArrowLogicalType (attribute);
354
355
if (attribute.metadata != nullptr && strncmp (attribute.metadata , ogc_flag, sizeof (ogc_flag)) == 0 ) {
355
356
// This is a WKB geometry blob
356
- GetArrowLogicalType (attribute, result->arrow_convert_data , col_idx );
357
+ result->arrow_table . AddColumn (col_idx, std::move (arrow_type) );
357
358
return_types.emplace_back (core::GeoTypes::WKB_BLOB ());
358
359
} else if (attribute.dictionary ) {
359
- result->arrow_convert_data [col_idx] =
360
- make_uniq<ArrowConvertData>(GetArrowLogicalType (attribute, result->arrow_convert_data , col_idx));
361
- return_types.emplace_back (GetArrowLogicalType (*attribute.dictionary , result->arrow_convert_data , col_idx));
360
+ auto dictionary_type = GetArrowLogicalType (attribute);
361
+ return_types.emplace_back (dictionary_type->GetDuckType ());
362
+ arrow_type->SetDictionary (std::move (dictionary_type));
363
+ result->arrow_table .AddColumn (col_idx, std::move (arrow_type));
362
364
} else {
363
- return_types.emplace_back (GetArrowLogicalType (attribute, result->arrow_convert_data , col_idx));
365
+ return_types.emplace_back (arrow_type->GetDuckType ());
366
+ result->arrow_table .AddColumn (col_idx, std::move (arrow_type));
364
367
}
365
368
366
369
// keep these around for projection/filter pushdown later
@@ -492,12 +495,12 @@ void GdalTableFunction::Scan(ClientContext &context, TableFunctionInput &input,
492
495
if (global_state.CanRemoveFilterColumns ()) {
493
496
state.all_columns .Reset ();
494
497
state.all_columns .SetCardinality (output_size);
495
- ArrowToDuckDB (state, data.arrow_convert_data , state.all_columns , data.lines_read - output_size, false );
498
+ ArrowToDuckDB (state, data.arrow_table . GetColumns () , state.all_columns , data.lines_read - output_size, false );
496
499
output.ReferenceColumns (state.all_columns , global_state.projection_ids );
497
500
} else {
498
501
output.SetCardinality (output_size);
499
502
500
- ArrowToDuckDB (state, data.arrow_convert_data , output, data.lines_read - output_size, false );
503
+ ArrowToDuckDB (state, data.arrow_table . GetColumns () , output, data.lines_read - output_size, false );
501
504
}
502
505
503
506
output.Verify ();
0 commit comments