duckdb / duckdb_spatial

MIT License
492 stars 41 forks source link

ST_Read crashes duckdb on Windows (but not Linux!) when reading from GeoJSON API #289

Closed daviewales closed 2 months ago

daviewales commented 8 months ago

To reproduce, run the following:

load httpfs;
load spatial;
SELECT * FROM ST_Read('https://services5.arcgis.com/OvOcYIrJnM97ABBA/ArcGIS/rest/services/Primary_Health_Network_2023/FeatureServer/0/query?where=PHN_CODE=%27PHN108%27&outFields=*&returnGeometry=true&f=geojson');

Expected:

┌────────────┬──────────────────────┬──────────┬─────────────────┬───┬──────────────────────┬──────────────────┬──────────────────┬──────────────────────┐
│ OBJECTID_1 │       PHN_NAME       │ PHN_CODE │    STE_NAME     │ … │       WEBSITE        │   Shape__Area    │  Shape__Length   │         geom         │
│   int32    │       varchar        │ varchar  │     varchar     │   │       varchar        │      double      │      double      │       geometry       │
├────────────┼──────────────────────┼──────────┼─────────────────┼───┼──────────────────────┼──────────────────┼──────────────────┼──────────────────────┤
│          1 │ Hunter New England…  │ PHN108   │ New South Wales │ … │ https://thephn.com…  │ 12.5523589729341 │ 38.0504026046165 │ MULTIPOLYGON (((15…  │
├────────────┴──────────────────────┴──────────┴─────────────────┴───┴──────────────────────┴──────────────────┴──────────────────┴──────────────────────┤
│ 1 rows                                                                                                                            15 columns (8 shown) │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Actual:

DuckDB crashes with no output.

Note that the above works perfectly in my WSL Linux version of duckdb.

Version Info:

OS: Windows 11 DuckDB version: v0.10.0 20b1486d11 spatial extension version: latest using FORCE INSTALL spatial FROM 'http://nightly-extensions.duckdb.org'; (Also broken with regular INSTALL spatial;) httpfs extension version: current release (whatever you get with INSTALL httpfs;)

cxcandid commented 7 months ago

Another option would be to use GDAL '/vsicurl/' to load remote data.

load spatial;
SELECT * FROM ST_Read('/vsicurl/https://services5.arcgis.com/OvOcYIrJnM97ABBA/ArcGIS/rest/services/Primary_Health_Network_2023/FeatureServer/0/query?where=PHN_CODE=%27PHN108%27&outFields=*&returnGeometry=true&f=geojson');

I had a similar problem yesterday, when I tried to fetch data from OSM Nominatim:

install spatial;
load spatial;
COPY (SELECT ST_Transform(geom,'EPSG:4326','EPSG:31287',true) as geom from ST_Read('/vsicurl/https://nominatim.openstreetmap.org/search?email=test@gmx.at&q=Austria&format=geojson&polygon_geojson=1&featureType=country&polygon_threshold=0.01')) to 'd:/austria.dxf' with (Format GDAL, Driver 'DXF');
carlopi commented 2 months ago

Hi @daviewales, can I ask whether this still reproduces ? Possibly via a FORCE INSTALL httpfs?

Thanks a lot

daviewales commented 2 months ago

Thanks, this no longer crashes!

carlopi commented 2 months ago

I think this was connected to https://github.com/duckdb/duckdb/issues/13848, but should now be fixed.