diff --git a/spatial/src/spatial/gdal/functions/st_write.cpp b/spatial/src/spatial/gdal/functions/st_write.cpp index b6c91a4b..56d5ecc1 100644 --- a/spatial/src/spatial/gdal/functions/st_write.cpp +++ b/spatial/src/spatial/gdal/functions/st_write.cpp @@ -338,6 +338,10 @@ static unique_ptr 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(); @@ -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 =