Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 3 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
1 change: 0 additions & 1 deletion duckdb-spatial
Submodule duckdb-spatial deleted from 04270f
13 changes: 3 additions & 10 deletions extension_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/generated/generated_aggregates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_13.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_15.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/generated/generated_temporal_udfs_9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/geo/geoset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion src/geo/stbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "duckdb/main/extension/extension_loader.hpp"
#include <duckdb/parser/parsed_data/create_scalar_function_info.hpp>
#include <scoped_allocator>
#include "spatial/spatial_types.hpp"
#include "mobilityduck/meos_exec_serial.hpp"

namespace duckdb {
Expand Down
2 changes: 1 addition & 1 deletion src/geo/stbox_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <cmath>
#include <string>

#include "spatial/spatial_types.hpp"
#include "duckdb_version_compat.hpp"

namespace duckdb {

Expand Down
1 change: 0 additions & 1 deletion src/geo/tgeogpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "duckdb/function/scalar_function.hpp"
#include "duckdb/main/extension/extension_loader.hpp"
#include <duckdb/parser/parsed_data/create_scalar_function_info.hpp>
#include "spatial/spatial_types.hpp"
#include "mobilityduck/meos_exec_serial.hpp"

#include "duckdb/common/extension_type_info.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/geo/tgeogpoint_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion src/geo/tgeogpoint_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
1 change: 0 additions & 1 deletion src/geo/tgeography.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "geo/geoset.hpp"
#include<time_util.hpp>
#include "geo_util.hpp"
#include "spatial/spatial_types.hpp"
#include "mobilityduck/meos_exec_serial.hpp"

extern "C" {
Expand Down
1 change: 0 additions & 1 deletion src/geo/tgeography_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
1 change: 0 additions & 1 deletion src/geo/tgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "geo/geoset.hpp"
#include<time_util.hpp>
#include "geo_util.hpp"
#include "spatial/spatial_types.hpp"
#include "mobilityduck/meos_exec_serial.hpp"

extern "C" {
Expand Down
1 change: 0 additions & 1 deletion src/geo/tgeometry_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
1 change: 0 additions & 1 deletion src/geo/tgeompoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "duckdb/function/table_function.hpp"
#include "duckdb/main/extension/extension_loader.hpp"
#include <duckdb/parser/parsed_data/create_scalar_function_info.hpp>
#include "spatial/spatial_types.hpp"
#include "mobilityduck/meos_exec_serial.hpp"
#include "geo_util.hpp"
#include "time_util.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/geo/tgeompoint_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
46 changes: 14 additions & 32 deletions src/include/duckdb_version_compat.hpp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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<data_t> &buffer) {
#if MOBILITYDUCK_DUCKDB_AT_LEAST(1, 5)
Vector source(LogicalType::GEOMETRY());
source.SetVectorType(VectorType::CONSTANT_VECTOR);
ConstantVector::GetData<string_t>(source)[0] = geometry;
Expand All @@ -75,9 +60,6 @@ inline void MobilityDuckGeometryToWKB(const string_t &geometry, vector<data_t> &
const auto wkb = ConstantVector::GetData<string_t>(target)[0];
const auto data = const_data_ptr_cast(wkb.GetData());
buffer.assign(data, data + wkb.GetSize());
#else
WKBWriter::Write(geometry, buffer);
#endif
}


Expand Down
Loading
Loading