duckdb / duckdb/duckdb-spatial

Can't create RTREE spatial index using new CRS-scoped GEOMETRY column type

Open
#824 4 comments 2 reactions 1 assignee Claimed by @Maxxen View on GitHub
bug
Dominant language
C
Stars
708
Forks
96
Avg merge
1d 21h
Merged PRs (30d)
5

Description

When trying to create a RTREE spatial index with a geometry field that has a CRS, I get an error that I can only do this on plain `GEOMETRY` columns. Here's a reproduction ([view example csv](https://gist.github.com/mhkeller/4dba2d7cff419aa64d622727c91ee3b8))

```sql
INSTALL spatial;
LOAD spatial;

.print '=== DuckDB version (need v1.5.0 or newer) ==='
SELECT version() AS duckdb_version;

.print '=== 1. Control: plain GEOMETRY + RTREE ==='

CREATE OR REPLACE TABLE lighthouses_plain AS
SELECT
name,
country,
longitude,
latitude,
height_m,
year_built,
ST_Point(longitude, latitude)::GEOMETRY AS geom
FROM read_csv_auto('lighthouses.csv');

CREATE INDEX IF NOT EXISTS lighthouses_plain_geom_idx
ON lighthouses_plain USING RTREE (geom);

.print '=== 2. Bug repro: GEOMETRY(''OGC:CRS84'') + RTREE ==='

CREATE OR REPLACE TABLE lighthouses_crs AS
SELECT
name,
country,
longitude,
latitude,
height_m,
year_built,
ST_Point(longitude, latitude)::GEOMETRY('OGC:CRS84') AS geom
FROM read_csv_auto('lighthouses.csv');

-- Binder Error: RTree indexes can only be created over GEOMETRY columns.
CREATE INDEX IF NOT EXISTS lighthouses_crs_geom_idx
ON lighthouses_crs USING RTREE (geom);

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.