Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix writing NULL geometries through GDAL #427

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion spatial/src/spatial/gdal/functions/st_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ static unique_ptr<GlobalFunctionData> InitGlobal(ClientContext &context, Functio
//===--------------------------------------------------------------------===//

static OGRGeometryUniquePtr OGRGeometryFromValue(const LogicalType &type, const Value &value, ArenaAllocator &arena) {
if(value.IsNull()) {
return nullptr;
}

if (type == core::GeoTypes::WKB_BLOB()) {
auto str = value.GetValueUnsafe<string_t>();

Expand Down Expand Up @@ -511,7 +515,7 @@ static void Sink(ExecutionContext &context, FunctionData &bdata, GlobalFunctionD
if (IsGeometryType(type)) {
// TODO: check how many geometry fields there are and use the correct one.
auto geom = OGRGeometryFromValue(type, value, local_state.arena);
if (bind_data.geometry_type != wkbUnknown && geom->getGeometryType() != bind_data.geometry_type) {
if (geom && bind_data.geometry_type != wkbUnknown && geom->getGeometryType() != bind_data.geometry_type) {
auto got_name =
StringUtil::Replace(StringUtil::Upper(OGRGeometryTypeToName(geom->getGeometryType())), " ", "");
auto expected_name =
Expand Down
Loading