diff --git a/.gitmodules b/.gitmodules index 00a79de3..86e8a7ee 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,6 +6,3 @@ path = extension-ci-tools url = https://github.com/duckdb/extension-ci-tools branch = main -[submodule "duckdb-spatial"] - path = duckdb-spatial - url = https://github.com/duckdb/duckdb-spatial diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c8031b9..d5f86b53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,11 +96,6 @@ set(EXTENSION_NAME ${TARGET_NAME}_extension) set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension) include_directories(src/include) -# Vendored duckdb-spatial headers are third-party: include them as SYSTEM so their -# warnings (e.g. the two sgl.hpp variants redefining SGL_ASSERT) do not surface in -# MobilityDuck translation units. MDB's own src/include stays non-SYSTEM (full warnings). -include_directories(SYSTEM duckdb-spatial/src) -include_directories(SYSTEM duckdb-spatial/src/spatial) set(EXTENSION_SOURCES src/spatial_ref_sys_csv.inc @@ -292,9 +287,9 @@ set(MOBILITYDUCK_LINK_LIBS ZLIB::ZLIB ) -# The GEOMETRY type and its WKB conversion live in the spatial extension on the -# v1.4 line and in DuckDB core from v1.5.0, so src/include/duckdb_version_compat.hpp -# selects between them. DuckDB's own build sets these two variables. +# src/include/duckdb_version_compat.hpp selects the DuckDB entry points of the line +# being built and refuses a line older than v1.5, where GEOMETRY is not yet a core +# type. DuckDB's own build sets these two variables. foreach(_md_target ${MOBILITYDUCK_COMPILE_TARGETS}) target_compile_definitions(${_md_target} PRIVATE MOBILITYDUCK_DUCKDB_MAJOR=${DUCKDB_MAJOR_VERSION} diff --git a/duckdb-spatial b/duckdb-spatial deleted file mode 160000 index 04270fe7..00000000 --- a/duckdb-spatial +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 04270fe7bb4eb412765cce8afde0276a9d81d3ba diff --git a/extension_config.cmake b/extension_config.cmake index 1747c942..85af1e2c 100644 --- a/extension_config.cmake +++ b/extension_config.cmake @@ -9,15 +9,8 @@ duckdb_extension_load(mobilityduck # Any extra extensions that should be built # e.g.: duckdb_extension_load(json) -# The spatial extension at the commit DuckDB v1.5.6 builds -# (.github/config/extensions/spatial.cmake). It carries the fix restricting the -# && spatial join rewrite to GEOMETRY operands (duckdb-spatial #853), without -# which the optimizer claims MobilityDuck's && joins. DuckDB v1.5.6 ships no -# patch for spatial. -duckdb_extension_load(spatial - GIT_URL https://github.com/duckdb/duckdb-spatial - GIT_TAG 04270fe7bb4eb412765cce8afde0276a9d81d3ba - INCLUDE_DIR src/spatial -) +# The spatial extension is not built here: MobilityDuck stacks on the spatial +# extension DuckDB publishes, which a session loads beside it, and the tests +# that call its ST_ functions install and load that published extension. duckdb_extension_load(icu) diff --git a/src/generated/generated_aggregates.cpp b/src/generated/generated_aggregates.cpp index fb59b7de..4b38d246 100644 --- a/src/generated/generated_aggregates.cpp +++ b/src/generated/generated_aggregates.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs.cpp b/src/generated/generated_temporal_udfs.cpp index 4c7a4439..0f9b4ff0 100644 --- a/src/generated/generated_temporal_udfs.cpp +++ b/src/generated/generated_temporal_udfs.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_0.cpp b/src/generated/generated_temporal_udfs_0.cpp index 1a2f70b5..663db7ad 100644 --- a/src/generated/generated_temporal_udfs_0.cpp +++ b/src/generated/generated_temporal_udfs_0.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_1.cpp b/src/generated/generated_temporal_udfs_1.cpp index 09728222..d27535b7 100644 --- a/src/generated/generated_temporal_udfs_1.cpp +++ b/src/generated/generated_temporal_udfs_1.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_10.cpp b/src/generated/generated_temporal_udfs_10.cpp index 06461683..68c62982 100644 --- a/src/generated/generated_temporal_udfs_10.cpp +++ b/src/generated/generated_temporal_udfs_10.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_11.cpp b/src/generated/generated_temporal_udfs_11.cpp index 5929f836..b7e8b34d 100644 --- a/src/generated/generated_temporal_udfs_11.cpp +++ b/src/generated/generated_temporal_udfs_11.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_12.cpp b/src/generated/generated_temporal_udfs_12.cpp index e69f7d66..8dbcb05c 100644 --- a/src/generated/generated_temporal_udfs_12.cpp +++ b/src/generated/generated_temporal_udfs_12.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_13.cpp b/src/generated/generated_temporal_udfs_13.cpp index d37237a2..37363feb 100644 --- a/src/generated/generated_temporal_udfs_13.cpp +++ b/src/generated/generated_temporal_udfs_13.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_14.cpp b/src/generated/generated_temporal_udfs_14.cpp index 1a5a629e..3af0cba5 100644 --- a/src/generated/generated_temporal_udfs_14.cpp +++ b/src/generated/generated_temporal_udfs_14.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_15.cpp b/src/generated/generated_temporal_udfs_15.cpp index cb6317e2..0b300959 100644 --- a/src/generated/generated_temporal_udfs_15.cpp +++ b/src/generated/generated_temporal_udfs_15.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_2.cpp b/src/generated/generated_temporal_udfs_2.cpp index b5ffc37c..6fda3ed1 100644 --- a/src/generated/generated_temporal_udfs_2.cpp +++ b/src/generated/generated_temporal_udfs_2.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_3.cpp b/src/generated/generated_temporal_udfs_3.cpp index 31a9c945..6dcba802 100644 --- a/src/generated/generated_temporal_udfs_3.cpp +++ b/src/generated/generated_temporal_udfs_3.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_4.cpp b/src/generated/generated_temporal_udfs_4.cpp index 53c146d2..fb157841 100644 --- a/src/generated/generated_temporal_udfs_4.cpp +++ b/src/generated/generated_temporal_udfs_4.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_5.cpp b/src/generated/generated_temporal_udfs_5.cpp index 915cb9bb..68f71bdb 100644 --- a/src/generated/generated_temporal_udfs_5.cpp +++ b/src/generated/generated_temporal_udfs_5.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_6.cpp b/src/generated/generated_temporal_udfs_6.cpp index 6a03a04d..ebc7a168 100644 --- a/src/generated/generated_temporal_udfs_6.cpp +++ b/src/generated/generated_temporal_udfs_6.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_7.cpp b/src/generated/generated_temporal_udfs_7.cpp index 0351d087..f0494301 100644 --- a/src/generated/generated_temporal_udfs_7.cpp +++ b/src/generated/generated_temporal_udfs_7.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_8.cpp b/src/generated/generated_temporal_udfs_8.cpp index 5d53533d..8e9cacd4 100644 --- a/src/generated/generated_temporal_udfs_8.cpp +++ b/src/generated/generated_temporal_udfs_8.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/generated/generated_temporal_udfs_9.cpp b/src/generated/generated_temporal_udfs_9.cpp index f13ad4a4..bedc2f7b 100644 --- a/src/generated/generated_temporal_udfs_9.cpp +++ b/src/generated/generated_temporal_udfs_9.cpp @@ -28,7 +28,7 @@ #include "posechain/tposechain.hpp" #include "raster/raquet.hpp" #include "raster/raster.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "geo_util.hpp" #include "meos_internal.h" #include "meos_geo.h" diff --git a/src/geo/geoset.cpp b/src/geo/geoset.cpp index e7fc004b..c89a2af7 100644 --- a/src/geo/geoset.cpp +++ b/src/geo/geoset.cpp @@ -7,7 +7,6 @@ #include "duckdb/common/extension_type_info.hpp" #include "duckdb/function/scalar_function.hpp" #include "duckdb/main/extension/extension_loader.hpp" -#include "spatial/spatial_types.hpp" #include "mobilityduck/meos_exec_serial.hpp" #include "temporal/set_functions.hpp" diff --git a/src/geo/stbox.cpp b/src/geo/stbox.cpp index c3f9747d..6453eb41 100644 --- a/src/geo/stbox.cpp +++ b/src/geo/stbox.cpp @@ -12,7 +12,6 @@ #include "duckdb/main/extension/extension_loader.hpp" #include #include -#include "spatial/spatial_types.hpp" #include "mobilityduck/meos_exec_serial.hpp" namespace duckdb { diff --git a/src/geo/stbox_functions.cpp b/src/geo/stbox_functions.cpp index 120cf399..e746d512 100644 --- a/src/geo/stbox_functions.cpp +++ b/src/geo/stbox_functions.cpp @@ -13,7 +13,7 @@ #include #include -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" namespace duckdb { diff --git a/src/geo/tgeogpoint.cpp b/src/geo/tgeogpoint.cpp index 120fb017..965146c2 100644 --- a/src/geo/tgeogpoint.cpp +++ b/src/geo/tgeogpoint.cpp @@ -17,7 +17,6 @@ #include "duckdb/function/scalar_function.hpp" #include "duckdb/main/extension/extension_loader.hpp" #include -#include "spatial/spatial_types.hpp" #include "mobilityduck/meos_exec_serial.hpp" #include "duckdb/common/extension_type_info.hpp" diff --git a/src/geo/tgeogpoint_functions.cpp b/src/geo/tgeogpoint_functions.cpp index 2d8094f0..183dfb00 100644 --- a/src/geo/tgeogpoint_functions.cpp +++ b/src/geo/tgeogpoint_functions.cpp @@ -10,7 +10,7 @@ #include "duckdb/common/vector.hpp" #include "duckdb/common/typedefs.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "duckdb/common/types.hpp" diff --git a/src/geo/tgeogpoint_ops.cpp b/src/geo/tgeogpoint_ops.cpp index 26ad1b1e..3fd0ab42 100644 --- a/src/geo/tgeogpoint_ops.cpp +++ b/src/geo/tgeogpoint_ops.cpp @@ -18,7 +18,6 @@ #include "duckdb/common/exception.hpp" #include "duckdb/function/scalar_function.hpp" #include "duckdb/main/extension/extension_loader.hpp" -#include "spatial/spatial_types.hpp" #include "mobilityduck/meos_exec_serial.hpp" extern "C" { diff --git a/src/geo/tgeography.cpp b/src/geo/tgeography.cpp index 85192241..b10faf64 100644 --- a/src/geo/tgeography.cpp +++ b/src/geo/tgeography.cpp @@ -13,7 +13,6 @@ #include "geo/geoset.hpp" #include #include "geo_util.hpp" -#include "spatial/spatial_types.hpp" #include "mobilityduck/meos_exec_serial.hpp" extern "C" { diff --git a/src/geo/tgeography_ops.cpp b/src/geo/tgeography_ops.cpp index eda2710b..b37488ee 100644 --- a/src/geo/tgeography_ops.cpp +++ b/src/geo/tgeography_ops.cpp @@ -19,7 +19,6 @@ #include "duckdb/common/exception.hpp" #include "duckdb/function/scalar_function.hpp" #include "duckdb/main/extension/extension_loader.hpp" -#include "spatial/spatial_types.hpp" #include "mobilityduck/meos_exec_serial.hpp" extern "C" { diff --git a/src/geo/tgeometry.cpp b/src/geo/tgeometry.cpp index 2f9e4bbf..a20ef2af 100644 --- a/src/geo/tgeometry.cpp +++ b/src/geo/tgeometry.cpp @@ -13,7 +13,6 @@ #include "geo/geoset.hpp" #include #include "geo_util.hpp" -#include "spatial/spatial_types.hpp" #include "mobilityduck/meos_exec_serial.hpp" extern "C" { diff --git a/src/geo/tgeometry_ops.cpp b/src/geo/tgeometry_ops.cpp index b64f9ac9..6fce8fdf 100644 --- a/src/geo/tgeometry_ops.cpp +++ b/src/geo/tgeometry_ops.cpp @@ -19,7 +19,6 @@ #include "duckdb/common/exception.hpp" #include "duckdb/function/scalar_function.hpp" #include "duckdb/main/extension/extension_loader.hpp" -#include "spatial/spatial_types.hpp" #include "mobilityduck/meos_exec_serial.hpp" extern "C" { diff --git a/src/geo/tgeompoint.cpp b/src/geo/tgeompoint.cpp index 4f50fb4e..bd4a511f 100644 --- a/src/geo/tgeompoint.cpp +++ b/src/geo/tgeompoint.cpp @@ -17,7 +17,6 @@ #include "duckdb/function/table_function.hpp" #include "duckdb/main/extension/extension_loader.hpp" #include -#include "spatial/spatial_types.hpp" #include "mobilityduck/meos_exec_serial.hpp" #include "geo_util.hpp" #include "time_util.hpp" diff --git a/src/geo/tgeompoint_functions.cpp b/src/geo/tgeompoint_functions.cpp index d9843945..190e7d6a 100644 --- a/src/geo/tgeompoint_functions.cpp +++ b/src/geo/tgeompoint_functions.cpp @@ -11,7 +11,7 @@ #include "duckdb/common/vector_operations/ternary_executor.hpp" #include "duckdb/common/typedefs.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "duckdb/common/types.hpp" diff --git a/src/include/duckdb_version_compat.hpp b/src/include/duckdb_version_compat.hpp index 8227c902..b5c430b5 100644 --- a/src/include/duckdb_version_compat.hpp +++ b/src/include/duckdb_version_compat.hpp @@ -1,15 +1,13 @@ #pragma once -// The DuckDB line being built decides two things this extension depends on. +// The DuckDB line being built decides the entry points this extension calls. // -// GEOMETRY is a spatial-extension type on the v1.4 line and a core DuckDB -// LogicalTypeId from v1.5.0 (duckdb/common/types/geometry.hpp records -// "Added to core in DuckDB v1.5.0"), so `MobilityDuckGeometryType()` names it on one -// line and `LogicalType::GEOMETRY()` on the other. The move takes the WKB -// conversion with it: the v1.4 spatial extension offers the scalar -// `WKBWriter::Write`, while core offers the vector-oriented -// `Geometry::ToBinary`, so the boundary that hands a geometry to MEOS is -// written once here rather than at each call site. +// GEOMETRY is a core DuckDB LogicalTypeId from v1.5.0 +// (duckdb/common/types/geometry.hpp records "Added to core in DuckDB v1.5.0"), +// with its WKB conversion `Geometry::ToBinary`; before v1.5 it is a type of the +// spatial extension, which MobilityDuck does not build, so v1.5 is the oldest +// line MobilityDuck builds against. The boundary that hands a geometry to MEOS +// is written once here rather than at each call site. // // MOBILITYDUCK_DUCKDB_MAJOR / _MINOR come from CMakeLists.txt, which reads the // DUCKDB_MAJOR_VERSION / DUCKDB_MINOR_VERSION variables DuckDB's own build sets. @@ -31,40 +29,27 @@ (MOBILITYDUCK_DUCKDB_MAJOR > (major) || \ (MOBILITYDUCK_DUCKDB_MAJOR == (major) && MOBILITYDUCK_DUCKDB_MINOR >= (minor))) -#if MOBILITYDUCK_DUCKDB_AT_LEAST(1, 5) -#include "duckdb/common/types/geometry.hpp" -#else -#include "spatial/spatial_types.hpp" -#include "spatial/geometry/wkb_writer.hpp" +#if !MOBILITYDUCK_DUCKDB_AT_LEAST(1, 5) +#error "MobilityDuck builds against DuckDB v1.5 or later, where GEOMETRY is a core type." #endif +#include "duckdb/common/types/geometry.hpp" + namespace duckdb { -//! The GEOMETRY logical type of the DuckDB line being built. +//! The GEOMETRY logical type of DuckDB core. inline LogicalType MobilityDuckGeometryType() { -#if MOBILITYDUCK_DUCKDB_AT_LEAST(1, 5) return LogicalType::GEOMETRY(); -#else - return GeoTypes::GEOMETRY(); -#endif } -//! Whether a value of this type is a geometry. -//! -//! The spatial extension gives GEOMETRY the BLOB physical type and names it by -//! its alias, so a dispatch on the line where GEOMETRY is an extension type -//! reads BLOB; from v1.5 core states it as a LogicalTypeId of its own. +//! Whether a value of this type is a geometry: core states GEOMETRY as a +//! LogicalTypeId of its own, and a BLOB holding WKB is read as one too. inline bool MobilityDuckIsGeometryType(const LogicalType &type) { -#if MOBILITYDUCK_DUCKDB_AT_LEAST(1, 5) return type.id() == LogicalTypeId::GEOMETRY || type.id() == LogicalTypeId::BLOB; -#else - return type.id() == LogicalTypeId::BLOB; -#endif } //! The WKB of one geometry value, as the byte buffer MEOS reads. inline void MobilityDuckGeometryToWKB(const string_t &geometry, vector &buffer) { -#if MOBILITYDUCK_DUCKDB_AT_LEAST(1, 5) Vector source(LogicalType::GEOMETRY()); source.SetVectorType(VectorType::CONSTANT_VECTOR); ConstantVector::GetData(source)[0] = geometry; @@ -75,9 +60,6 @@ inline void MobilityDuckGeometryToWKB(const string_t &geometry, vector & const auto wkb = ConstantVector::GetData(target)[0]; const auto data = const_data_ptr_cast(wkb.GetData()); buffer.assign(data, data + wkb.GetSize()); -#else - WKBWriter::Write(geometry, buffer); -#endif } diff --git a/src/include/geo_util.hpp b/src/include/geo_util.hpp index a954a18a..9379dd0c 100644 --- a/src/include/geo_util.hpp +++ b/src/include/geo_util.hpp @@ -9,13 +9,7 @@ #include "duckdb/storage/arena_allocator.hpp" #include "duckdb/execution/expression_executor_state.hpp" #include "duckdb_version_compat.hpp" -#if MOBILITYDUCK_DUCKDB_AT_LEAST(1, 5) #include "duckdb/common/types/geometry_crs.hpp" -#endif -#if !MOBILITYDUCK_DUCKDB_AT_LEAST(1, 5) -#include "spatial/geometry/geometry_serialization.hpp" -#include "spatial/geometry/sgl.hpp" -#endif namespace duckdb { @@ -43,7 +37,6 @@ inline GSERIALIZED* GeometryToGSerialized(string_t geometry_blob, int32_t srid) * SRID MEOS reads, and is refused rather than read as none. */ inline int32_t GeometryCrsSrid(const LogicalType &type) { -#if MOBILITYDUCK_DUCKDB_AT_LEAST(1, 5) // a list of geometries states the CRS of its element type if (type.id() == LogicalTypeId::LIST) { return GeometryCrsSrid(ListType::GetChildType(type)); @@ -66,10 +59,6 @@ inline int32_t GeometryCrsSrid(const LogicalType &type) { return (int32_t) std::stoi(code); } throw InvalidInputException("The coordinate reference system '%s' of a GEOMETRY names no EPSG code", id); -#else - (void) type; - return 0; -#endif } inline string_t GSerializedToGeometry(const GSERIALIZED *gs, ArenaAllocator &arena, Vector &result) { @@ -83,7 +72,6 @@ inline string_t GSerializedToGeometry(const GSERIALIZED *gs, ArenaAllocator &are throw InvalidInputException("Failed to convert GSERIALIZED to EWKB"); } -#if MOBILITYDUCK_DUCKDB_AT_LEAST(1, 5) // DuckDB core reads EWKB itself: it drops the SRID and writes the // little-endian ISO WKB its GEOMETRY type stores, so a loadable extension // needs none of the spatial extension's code for this conversion. @@ -98,31 +86,6 @@ inline string_t GSerializedToGeometry(const GSERIALIZED *gs, ArenaAllocator &are } free(ewkb_data); return blob; -#else - GeometryAllocator alloc(arena); - sgl::wkb_reader reader(alloc); - reader.set_allow_mixed_zm(true); - reader.set_nan_as_empty(true); - - sgl::geometry geom; - if (!reader.try_parse(geom, reinterpret_cast(ewkb_data), ewkb_size)) { - const auto error = reader.get_error_message(); - free(ewkb_data); - throw InvalidInputException("Could not parse EWKB input: %s", error); - } - - if (reader.parsed_mixed_zm()) { - sgl::ops::force_zm(alloc, geom, reader.parsed_any_z(), reader.parsed_any_m(), 0, 0); - } - - const auto size = Serde::GetRequiredSize(geom); - auto blob = StringVector::EmptyString(result, size); - Serde::Serialize(geom, blob.GetDataWriteable(), size); - blob.Finalize(); - - free(ewkb_data); - return blob; -#endif } inline string_t GSerializedToGeometry(const GSERIALIZED *gs, ExpressionState &state, Vector &result) { diff --git a/src/mobilityduck_extension.cpp b/src/mobilityduck_extension.cpp index 51e79b60..a40709af 100644 --- a/src/mobilityduck_extension.cpp +++ b/src/mobilityduck_extension.cpp @@ -489,15 +489,12 @@ static void LoadInternal(ExtensionLoader &loader) { TemporalParquetFunctions::Register(loader); } -// A static build registers the spatial extension it links through the -// extension loader DuckDB generates for it. A loadable extension runs in a -// DuckDB that links no such loader, so it loads the spatial extension the user -// has installed, the way LoadInternal loads ICU, and reports rather than fails -// when none is available; its object never names ExtensionHelper::LoadExtension, -// which a linker that keeps every function of an object (MinGW's) would -// otherwise fail to resolve. +// MobilityDuck links no spatial extension: it loads the one DuckDB publishes +// that the user has installed, the way LoadInternal loads ICU, and reports +// rather than fails when none is available. Its object never names +// ExtensionHelper::LoadExtension, which a linker that keeps every function of an +// object (MinGW's) would otherwise fail to resolve. static void LoadSpatial(DatabaseInstance &db) { -#if defined(DUCKDB_BUILD_LOADABLE_EXTENSION) try { ExtensionHelper::AutoLoadExtension(db, "spatial"); } catch (const std::exception &e) { @@ -505,10 +502,6 @@ static void LoadSpatial(DatabaseInstance &db) { "mobilityduck: spatial extension not available (%s); its " "functions are not loaded.\n", e.what()); } -#else - DuckDB db_wrapper(db); - ExtensionHelper::LoadExtension(db_wrapper, "spatial"); -#endif } // DuckDB runs extension optimizers in the order they register, so MobilityDuck diff --git a/src/pointcloud/tpcpatch.cpp b/src/pointcloud/tpcpatch.cpp index 918ed873..c3ccc3d3 100644 --- a/src/pointcloud/tpcpatch.cpp +++ b/src/pointcloud/tpcpatch.cpp @@ -12,7 +12,7 @@ #include "geo/geoset.hpp" #include #include "geo_util.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "mobilityduck/meos_exec_serial.hpp" #include "tydef.hpp" diff --git a/src/pointcloud/tpcpoint.cpp b/src/pointcloud/tpcpoint.cpp index 1ec4ae9d..7e31f6b4 100644 --- a/src/pointcloud/tpcpoint.cpp +++ b/src/pointcloud/tpcpoint.cpp @@ -12,7 +12,7 @@ #include "geo/geoset.hpp" #include #include "geo_util.hpp" -#include "spatial/spatial_types.hpp" +#include "duckdb_version_compat.hpp" #include "mobilityduck/meos_exec_serial.hpp" #include "tydef.hpp" diff --git a/test/sql/container_comparison.test b/test/sql/container_comparison.test index bff7b140..8ef2cbe8 100644 --- a/test/sql/container_comparison.test +++ b/test/sql/container_comparison.test @@ -8,6 +8,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # posechain/expected/551_posechainset.test.out:210 query I SELECT cmp(posechainset '{"PoseChain(Pose(Point(0 0), 0))"}', posechainset '{"PoseChain(Pose(Point(0 0), 0))"}'); diff --git a/test/sql/h3_prefilter.test b/test/sql/h3_prefilter.test index 83aeffa6..dfebf61d 100644 --- a/test/sql/h3_prefilter.test +++ b/test/sql/h3_prefilter.test @@ -10,6 +10,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # A region cell-set at the trip's own location shares the trip's H3 cell -> true. query I SELECT eEqual(geoToH3IndexSet(ST_Point(1, 1), 5), diff --git a/test/sql/parity/025_temporal_tile_split_forms.test b/test/sql/parity/025_temporal_tile_split_forms.test index b188dff1..2281c131 100644 --- a/test/sql/parity/025_temporal_tile_split_forms.test +++ b/test/sql/parity/025_temporal_tile_split_forms.test @@ -5,6 +5,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + statement ok SET TimeZone='America/Los_Angeles' diff --git a/test/sql/parity/026_single_tile_getters.test b/test/sql/parity/026_single_tile_getters.test index ebb11a8a..2bcd4453 100644 --- a/test/sql/parity/026_single_tile_getters.test +++ b/test/sql/parity/026_single_tile_getters.test @@ -10,6 +10,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # ============================================================================= # getValueTile(double, double [, double=0.0]) -> tbox # ============================================================================= diff --git a/test/sql/parity/040_tgeometry_parity.test b/test/sql/parity/040_tgeometry_parity.test index a182f98d..0a9c7749 100644 --- a/test/sql/parity/040_tgeometry_parity.test +++ b/test/sql/parity/040_tgeometry_parity.test @@ -19,6 +19,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # ============================================================================= # Accessors # ============================================================================= diff --git a/test/sql/parity/054_tspatial_compops.test b/test/sql/parity/054_tspatial_compops.test index a50cabc8..5f23c69c 100644 --- a/test/sql/parity/054_tspatial_compops.test +++ b/test/sql/parity/054_tspatial_compops.test @@ -8,6 +8,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # eEqual across (geo × tgeo, tgeo × geo, tgeo × tgeo) query I diff --git a/test/sql/parity/058_tpoint_tile.test b/test/sql/parity/058_tpoint_tile.test index 05b25116..e7d5a85c 100644 --- a/test/sql/parity/058_tpoint_tile.test +++ b/test/sql/parity/058_tpoint_tile.test @@ -12,6 +12,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + statement ok SET TimeZone='America/Los_Angeles' diff --git a/test/sql/parity/058b_tpoint_split.test b/test/sql/parity/058b_tpoint_split.test index 2ce3e250..8d92f6f2 100644 --- a/test/sql/parity/058b_tpoint_split.test +++ b/test/sql/parity/058b_tpoint_split.test @@ -6,6 +6,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # The bins of UTC-midnight data under the default origin, which MobilityDB reads in the session # time zone statement ok diff --git a/test/sql/parity/058c_tpoint_split_lateral.test b/test/sql/parity/058c_tpoint_split_lateral.test index 2accbeff..cac6844d 100644 --- a/test/sql/parity/058c_tpoint_split_lateral.test +++ b/test/sql/parity/058c_tpoint_split_lateral.test @@ -6,6 +6,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # The bins of UTC-midnight data under the default origin, which MobilityDB reads in the session # time zone statement ok diff --git a/test/sql/parity/064_tpoint_distance.test b/test/sql/parity/064_tpoint_distance.test index 6298310b..ac83ac2c 100644 --- a/test/sql/parity/064_tpoint_distance.test +++ b/test/sql/parity/064_tpoint_distance.test @@ -7,6 +7,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # ============================================================================= # tdistance (named form of <->) # ============================================================================= diff --git a/test/sql/parity/076_asmvtgeom_geomeasure.test b/test/sql/parity/076_asmvtgeom_geomeasure.test index 886cfa30..e620debf 100644 --- a/test/sql/parity/076_asmvtgeom_geomeasure.test +++ b/test/sql/parity/076_asmvtgeom_geomeasure.test @@ -7,6 +7,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # asMVTGeom returns a STRUCT(geom GEOMETRY, times BIGINT[]) query I diff --git a/test/sql/parity/076_tspatial_transforms.test b/test/sql/parity/076_tspatial_transforms.test index d80cac16..b799ad8c 100644 --- a/test/sql/parity/076_tspatial_transforms.test +++ b/test/sql/parity/076_tspatial_transforms.test @@ -5,6 +5,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # affine 12-arg core (3D affine matrix + translation) query I diff --git a/test/sql/parity/076b_tspatial_transform_stragglers.test b/test/sql/parity/076b_tspatial_transform_stragglers.test index e17c4780..7f33206b 100644 --- a/test/sql/parity/076b_tspatial_transform_stragglers.test +++ b/test/sql/parity/076b_tspatial_transform_stragglers.test @@ -5,6 +5,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # rotate(tgeompoint, double, geometry) — rotate angle around (ST_X, ST_Y) # pi rotation around (1, 0) maps (2, 0) -> (0, 0) diff --git a/test/sql/parity/093_split_n_boxes.test b/test/sql/parity/093_split_n_boxes.test index b13dcab2..82ef2f54 100644 --- a/test/sql/parity/093_split_n_boxes.test +++ b/test/sql/parity/093_split_n_boxes.test @@ -7,6 +7,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # A 5-instant trajectory whose points are not collinear, so normalization keeps # all four segments: stboxes returns one box per segment. diff --git a/test/sql/parity/096_index_constructor_operand.test b/test/sql/parity/096_index_constructor_operand.test index f865d21f..2b46c217 100644 --- a/test/sql/parity/096_index_constructor_operand.test +++ b/test/sql/parity/096_index_constructor_operand.test @@ -4,6 +4,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + statement ok CREATE TABLE box_idx(box stbox, label varchar); diff --git a/test/sql/parity/097_box_functions.test b/test/sql/parity/097_box_functions.test index 3c8d52e6..b37f7033 100644 --- a/test/sql/parity/097_box_functions.test +++ b/test/sql/parity/097_box_functions.test @@ -7,6 +7,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # --------------------------------------------------------------------------- # The measures of a spatiotemporal box, with and without the default of their flag # --------------------------------------------------------------------------- diff --git a/test/sql/parity/098_box_constructors.test b/test/sql/parity/098_box_constructors.test index e555a0e9..2a0072c0 100644 --- a/test/sql/parity/098_box_constructors.test +++ b/test/sql/parity/098_box_constructors.test @@ -9,6 +9,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # --------------------------------------------------------------------------- # A temporal box from a value and a timestamp or a period # --------------------------------------------------------------------------- diff --git a/test/sql/parity/100_temporal_constructors.test b/test/sql/parity/100_temporal_constructors.test index 05657ccc..e921b8b5 100644 --- a/test/sql/parity/100_temporal_constructors.test +++ b/test/sql/parity/100_temporal_constructors.test @@ -12,6 +12,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # --------------------------------------------------------------------------- # An alphanumeric temporal value from a value and a timestamp, a set, a span or a span set # --------------------------------------------------------------------------- diff --git a/test/sql/parity/102_temporal_leftovers.test b/test/sql/parity/102_temporal_leftovers.test index 4db35d11..481c41ea 100644 --- a/test/sql/parity/102_temporal_leftovers.test +++ b/test/sql/parity/102_temporal_leftovers.test @@ -14,6 +14,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # --------------------------------------------------------------------------- # tsample, with the time origin, its default '2000-01-03' and the interpolation # --------------------------------------------------------------------------- diff --git a/test/sql/parquet/temporal_parquet.test b/test/sql/parquet/temporal_parquet.test index 99a29398..64b1eaf7 100644 --- a/test/sql/parquet/temporal_parquet.test +++ b/test/sql/parquet/temporal_parquet.test @@ -4,6 +4,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + require parquet # ============================================================================= diff --git a/test/sql/raster.test b/test/sql/raster.test index 1b8127b1..85554da8 100644 --- a/test/sql/raster.test +++ b/test/sql/raster.test @@ -5,6 +5,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # The instants of the trajectory are read and written in UTC. statement ok SET TimeZone = 'UTC'; diff --git a/test/sql/raster_value.test b/test/sql/raster_value.test index a38fb824..6576cb00 100644 --- a/test/sql/raster_value.test +++ b/test/sql/raster_value.test @@ -4,6 +4,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # test/data/raster_4326.tif is a 2x2 UINT8 raster covering the world in WGS 84, # one pixel per quadrant: # NW lon -180..0 lat 0..90 = 1 NE lon 0..180 lat 0..90 = 2 diff --git a/test/sql/set_declared_signature.test b/test/sql/set_declared_signature.test index 3605a209..d03ede10 100644 --- a/test/sql/set_declared_signature.test +++ b/test/sql/set_declared_signature.test @@ -6,6 +6,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # ── jsonbsetDelete(jsonbset, text) removes the key from every element ── query I diff --git a/test/sql/static_cells.test b/test/sql/static_cells.test index cc0cf756..d9666595 100644 --- a/test/sql/static_cells.test +++ b/test/sql/static_cells.test @@ -6,6 +6,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # ── h3index: resolution and hierarchy (h3/expected/252_h3index_ops.test.out:1-50) ── query III diff --git a/test/sql/stbox.test b/test/sql/stbox.test index 4e092011..c27c00f2 100644 --- a/test/sql/stbox.test +++ b/test/sql/stbox.test @@ -1,5 +1,11 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + query I SELECT stbox 'STBOX X((1.0,2.0),(3.0,4.0))'; ---- diff --git a/test/sql/tcbuffer.test b/test/sql/tcbuffer.test index 6bc04bf0..6ff47218 100644 --- a/test/sql/tcbuffer.test +++ b/test/sql/tcbuffer.test @@ -4,6 +4,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # --------------------------------------------------------------------------- # Type + text I/O (hand-registered boundary; the point renders as HEXEWKB, the # canonical #Cbuffer_out() form — asText produces the WKT POINT(..) form). diff --git a/test/sql/tgeogpoint.test b/test/sql/tgeogpoint.test index 66caa04f..abdd9372 100644 --- a/test/sql/tgeogpoint.test +++ b/test/sql/tgeogpoint.test @@ -1,5 +1,11 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # ────────────────────────────────────────────────────────────────────────────── # Construction # ────────────────────────────────────────────────────────────────────────────── diff --git a/test/sql/tgeometry.test b/test/sql/tgeometry.test index befc4d9f..946af0e7 100644 --- a/test/sql/tgeometry.test +++ b/test/sql/tgeometry.test @@ -1,5 +1,11 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # Test tgeometry constructor with parentheses query I SELECT tgeometry('[Point(0 0)@2017-01-01 08:00:00, Linestring(0 0,0 1)@2017-01-02 08:05:00]'); diff --git a/test/sql/tgeompoint.test b/test/sql/tgeompoint.test index 3a810d27..53790623 100644 --- a/test/sql/tgeompoint.test +++ b/test/sql/tgeompoint.test @@ -1,5 +1,11 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + query I SELECT tgeompoint 'Point(1 1)@2012-01-01 08:00:00'; ---- diff --git a/test/sql/trgeometry.test b/test/sql/trgeometry.test index 7a9ec975..dbd049a6 100644 --- a/test/sql/trgeometry.test +++ b/test/sql/trgeometry.test @@ -5,6 +5,12 @@ require mobilityduck +statement ok +INSTALL spatial; + +statement ok +LOAD spatial; + # --------------------------------------------------------------------------- # Type + text I/O (hand-registered boundary). The cast prints the reference # geometry as HEXEWKB and the pose as the canonical #Pose_out() form; asText diff --git a/tools/codegen_duck_udfs.py b/tools/codegen_duck_udfs.py index 2a66bded..bc7fc37c 100644 --- a/tools/codegen_duck_udfs.py +++ b/tools/codegen_duck_udfs.py @@ -8875,7 +8875,7 @@ def gen_cpp(fns, out_path, declared=None, aliases=None): '#include "posechain/tposechain.hpp"\n' # PosechainTypes::posechain()/tposechain() '#include "raster/raquet.hpp"\n' # RaquetTypes::raquet() '#include "raster/raster.hpp"\n' # RasterTypes::raster() - '#include "spatial/spatial_types.hpp"\n' # MobilityDuckGeometryType() (duckdb-spatial) + '#include "duckdb_version_compat.hpp"\n' # MobilityDuckGeometryType() (DuckDB core GEOMETRY) '#include "geo_util.hpp"\n' # GeometryToGSerialized(blob, srid) '#include "meos_internal.h"\n' '#include "meos_geo.h"\n' diff --git a/vcpkg.json b/vcpkg.json index 7f19457d..72e9915e 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -46,8 +46,7 @@ "vcpkg-configuration": { "overlay-ports": [ "./extension-ci-tools/vcpkg_ports", - "./vcpkg_ports", - "./duckdb-spatial/vcpkg_ports" + "./vcpkg_ports" ] } }