duckdb / duckdb_spatial

MIT License
455 stars 33 forks source link

Backups (Export / Import) of tables with spatial types do not work. #98

Open michael-simons opened 1 year ago

michael-simons commented 1 year ago

Given

duckdb -s "
install spatial;
load spatial;
create table test(id int, foobar geometry);
insert into test values(1, ST_GeomFromText('POLYGON((1 2,1 4,3 4,3 2,1 2))'));
" test.db

Exporting with Spatial extension loaded as CSV

duckdb -s "
load spatial;
export database 'exp1';
" test.db

duckdb -s "
load spatial;
import database 'exp1';
SELECT * FROM test;
"

Results in

libc++abi: terminating due to uncaught exception of type duckdb::NotImplementedException: Not implemented Error: Deserialize::Geometry type not implemented yet!

Exporting with Spatial extension loaded as Parquet

duckdb -s "
load spatial;
export database 'exp2' (FORMAT PARQUET);
" test.db

duckdb -s "
load spatial;
import database 'exp2';
"

Results in

Error: Conversion Error: Unimplemented type for cast (BLOB -> GEOMETRY)

(Failing earlier than CSV)

CSV export without the spatial extension loaded works

duckdb -s "
export database 'exp3';
" test.db

duckdb -s "
load spatial;
import database 'exp3';
SELECT * FROM test;
"

Parquet does not.

CSV contains the wkt as export data when spatial is loaded, binary otherwise. Seems to be the difference here.

Maxxen commented 10 months ago

Hi! Thanks for reporting this issue, and sorry that I haven't gotten to it earlier. The csv export/import has been implemented in #172, but not parquet. Ill leave this issue open until I manage to get it working for parquet as well.

michael-simons commented 10 months ago

Looking forward to try this out! Thanks for taking care!