Extensions (spatial extension) with duckdb

Has anyone tried to use a duckdb extension in observable with any luck? The spatial extension would be amazing to use with geoparquet datasets. I’ve tried to install it in a connection query con.query(INSTALL spatial) and recieve the error “Error: IO Error: Can’t find the home directory at ‘/home/web_user’
Specify a home directory using the SET home_directory=‘/path/to/dir’ option.” Is this possible/does anyone have any good work around for loading and querying large geoparquet datasets in observable?

2 Likes

The DuckDB-Wasm version used by Observable is currently a few versions behind. Once it has caught up you should be able to use extensions as described here: Extensions for DuckDB-Wasm - DuckDB

You can follow the progress in this issue: Update duckdb-wasm to latest · Issue #588 · observablehq/feedback · GitHub

1 Like

I can’t wait…

1 Like

No news yet? No calendar?

1 Like

@neocarto It is possible to work around by using the latest version of the duckdb-wasm package installed from NPM, rather than the one built in with Observable. You have to manually setup the DB (or just pull the newest client from this notebook). From there you can install and load the spatial extension without issue. Happy to send along a brief example if useful.

1 Like

I would appreciate to see a notebook with a minimal example of spatial request with duckdb

@neocarto Here you go! Hope it helps! DuckDB Spatial Extensions in Observable Notebooks / Brayden Youngberg's Workspace | Observable

Thank you. Its works. But I need to re-run the cell containing the sql query for the notebook to execute properly

Fixed by placing adding the table when creating the initial connection, Cheers!

1 Like