Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COPY () TO WITH FORMAT OpenFileGDB failing #233

Closed
mtravis opened this issue Jan 19, 2024 · 1 comment · Fixed by #249
Closed

COPY () TO WITH FORMAT OpenFileGDB failing #233

mtravis opened this issue Jan 19, 2024 · 1 comment · Fixed by #249

Comments

@mtravis
Copy link

mtravis commented Jan 19, 2024

When using trying to write out to OpenFileGDB an error occurs.

COPY (select * from *.parquet') to 'admins.gdb' with (format GDAL, DRIVER 'OpenFileGDB');`

produces

ERROR 6: Unsupported geometry type
Error: IO Error: Could not create layer

More detail in this discussion

@Maxxen
Copy link
Member

Maxxen commented Jan 19, 2024

The issue you have is different from the original one. When you COPY (select * FROM *.parquet) you get the geometries as a WKB-encoded BLOB (because DuckDB does not natively support geoparquet yet). When you feed this into the spatial gdal driver it gets confused since WKB is not the same as DuckDB's internal GEOMETRY encoding.

You need to convert the original geometry from WKB into GEOMETRY using ST_GeomFromWKB(blob)

E.g.

COPY (select * exclude(geometry), st_geomfromwkb(geometry) as geometry from *.parquet') to 'admins.gdb' with (format GDAL, DRIVER 'OpenFileGDB');`

However, the original issue still remains. The problem is that File Geodatabases can't have mixed geometry types in a single layer, but DuckDB's GEOMETRY type is mixed by default. The solution is probably to add an additional optional parameter to st_write to "force" the layer to be created with a specific geometry type, or throw if a geometry of a different type is encountered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants