duckdb / duckdb_spatial

MIT License
492 stars 41 forks source link

Spatial Wasm build fails to install/load #326

Closed enlore closed 5 months ago

enlore commented 6 months ago

I'm attempting to load the spatial wasm build in the browser so I can render a map.

We're on DuckDB Wasm 0.10.3.

Context: we are working with MotherDuck and they just updated their client so that the DuckDB Wasm 0.10.3 client is a dependency. Previously they were providing a custom DuckDB build but that is no longer the case.

Screenshot 2024-05-31 at 12 08 03 PM

I performed a hard refresh and cleared the browser's cache.

Install and load commands:

install spatial
load spatial

GET is OK, and not being served from cache.

Request URL: https://extensions.duckdb.org/v0.10.3/wasm_eh/spatial.duckdb_extension.wasm
Request Method: GET
Status Code: 200 OK

Extension throws:

duckdb-browser-eh.worker.89b1b74700c211ba7343.js:1 Error: Invalid Input Error: Initialization function "spatial_init" from file "https://extensions.duckdb.org/v0.10.3/wasm_eh/spatial.duckdb_extension.wasm" threw an exception: "/MAX/SUM/AVG/COUNT implementation"
    at fa.startPendingQuery (duckdb-browser-eh.worker.89b1b74700c211ba7343.js:1:768450)
    at Ao.onMessage (duckdb-browser-eh.worker.89b1b74700c211ba7343.js:1:756674)
    at Rc.globalThis.onmessage (duckdb-browser-eh.worker.89b1b74700c211ba7343.js:1:789955)

Spatial functions not available in the catalog:

  SELECT DISTINCT ON(function_name)
    function_name,
    description
  FROM duckdb_functions()
  WHERE function_name LIKE 'ST_%'
  ORDER BY function_name

Using console.table() to print a nice table of functions. Table has no results: Screenshot 2024-05-31 at 12 14 15 PM

And finally, we attempt to render the map:

index.ts:71 
duckdb-browser-eh.wo…4700c211ba7343.js:1 Error: Catalog Error: Scalar Function with name "st_x" is not in the catalog, but it exists in the spatial extension.

Please try installing and loading the spatial extension:
INSTALL spatial;
LOAD spatial;

    at fa.startPendingQuery (duckdb-browser-eh.wo…1ba7343.js:1:768450)
    at Ao.onMessage (duckdb-browser-eh.wo…1ba7343.js:1:756674)
    at Rc.globalThis.onmessage (duckdb-browser-eh.wo…1ba7343.js:1:789955)

One last detail: it worked previously. I was able to load the extension, see the relevant functions added to the catalog, and render my map.

Let me know if I can provide any additional detail. Thank you in advance.

carlopi commented 5 months ago

I think this should be working properly now, both v1.0.0 and v0.10.3

Thanks for raising this.

enlore commented 5 months ago

Confirmed, spatial loads and map renders.

Much appreciated!