duckdb-r icon indicating copy to clipboard operation
duckdb-r copied to clipboard

Interop with spatial extension

Open krlmlr opened this issue 3 months ago • 2 comments

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 "use st_as_ewkb() before collect(), 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 .

krlmlr avatar Mar 22 '24 08:03 krlmlr