Skip to content

Commit

Permalink
Merge pull request #427 from Maxxen/dev
Browse files Browse the repository at this point in the history
Fix writing NULL geometries through GDAL
  • Loading branch information
Maxxen authored Oct 10, 2024
2 parents 9c14a8b + 519ad29 commit 3f94d52
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit 3f94d52

Please sign in to comment.