duckdb-r
duckdb-r copied to clipboard
Interop with spatial extension
From https://github.com/duckdb/duckdb-r/issues/55#issuecomment-2012742409:
Perhaps not a complete summary, but:
- Right now when a database result contains a column that comes from the DuckDB spatial extension, it shows up in Arrow output as a
list(raw())
where each element contains an opaque internal binary representation. This often leads to confusion because the format can't be read anywhere except DuckDB. I think the same is true of a database result that does not go through Arrow (i.e., R/DBI) but I haven't checked. - For a database result accessed via R/DBI, I imagine that you might have enough information available to you at "convert to R" time to at least give it a class. That class could implement
st::as_sfc()
and give an error along the lines of "usest_as_ewkb()
beforecollect()
, which is the workaround. - For a database result accessed via Arrow, the solution is complex because DuckDB does not currently have a way for an extension type to customize its arrow output ( https://github.com/duckdb/duckdb_spatial/issues/153 ).
CC @paleolimbot @eitsupi @cboettig .