Skip to content

Commit

Permalink
Merge pull request #121 from carlopi/patches
Browse files Browse the repository at this point in the history
Apply patch from duckdb/duckdb#8430 and update duckdb to latest main
  • Loading branch information
Maxxen authored Aug 31, 2023
2 parents f07879f + 0b8fb3e commit 2f55d5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion duckdb
Submodule duckdb updated 807 files
19 changes: 11 additions & 8 deletions spatial/src/spatial/gdal/functions/st_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ struct GdalScanFunctionData : public TableFunctionData {
vector<string> layer_creation_options;
unique_ptr<SpatialFilter> spatial_filter;
GDALDatasetUniquePtr dataset;
unordered_map<idx_t, unique_ptr<ArrowConvertData>> arrow_convert_data;
idx_t max_threads;
// before they are renamed
vector<string> all_names;
vector<LogicalType> all_types;
atomic<idx_t> lines_read;
ArrowTableType arrow_table;
};

struct GdalScanLocalState : ArrowScanLocalState {
Expand Down Expand Up @@ -351,16 +351,19 @@ unique_ptr<FunctionData> GdalTableFunction::Bind(ClientContext &context, TableFu
':', 'e', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', ':', 'n', 'a',
'm', 'e', '\a', '\0', '\0', '\0', 'o', 'g', 'c', '.', 'w', 'k', 'b'};

auto arrow_type = GetArrowLogicalType(attribute);
if (attribute.metadata != nullptr && strncmp(attribute.metadata, ogc_flag, sizeof(ogc_flag)) == 0) {
// This is a WKB geometry blob
GetArrowLogicalType(attribute, result->arrow_convert_data, col_idx);
result->arrow_table.AddColumn(col_idx, std::move(arrow_type));
return_types.emplace_back(core::GeoTypes::WKB_BLOB());
} else if (attribute.dictionary) {
result->arrow_convert_data[col_idx] =
make_uniq<ArrowConvertData>(GetArrowLogicalType(attribute, result->arrow_convert_data, col_idx));
return_types.emplace_back(GetArrowLogicalType(*attribute.dictionary, result->arrow_convert_data, col_idx));
auto dictionary_type = GetArrowLogicalType(attribute);
return_types.emplace_back(dictionary_type->GetDuckType());
arrow_type->SetDictionary(std::move(dictionary_type));
result->arrow_table.AddColumn(col_idx, std::move(arrow_type));
} else {
return_types.emplace_back(GetArrowLogicalType(attribute, result->arrow_convert_data, col_idx));
return_types.emplace_back(arrow_type->GetDuckType());
result->arrow_table.AddColumn(col_idx, std::move(arrow_type));
}

// keep these around for projection/filter pushdown later
Expand Down Expand Up @@ -492,12 +495,12 @@ void GdalTableFunction::Scan(ClientContext &context, TableFunctionInput &input,
if (global_state.CanRemoveFilterColumns()) {
state.all_columns.Reset();
state.all_columns.SetCardinality(output_size);
ArrowToDuckDB(state, data.arrow_convert_data, state.all_columns, data.lines_read - output_size, false);
ArrowToDuckDB(state, data.arrow_table.GetColumns(), state.all_columns, data.lines_read - output_size, false);
output.ReferenceColumns(state.all_columns, global_state.projection_ids);
} else {
output.SetCardinality(output_size);

ArrowToDuckDB(state, data.arrow_convert_data, output, data.lines_read - output_size, false);
ArrowToDuckDB(state, data.arrow_table.GetColumns(), output, data.lines_read - output_size, false);
}

output.Verify();
Expand Down

0 comments on commit 2f55d5d

Please sign in to comment.