Open asfimport opened 2 years ago
Weston Pace / @westonpace:
I wonder if ignoring the R metadata for query engine output would be a better strategy. If it's not the default, it would be nice to provide an escape hatch for users or developers that find themselves in this position with no workaround.
This would be my assumption. The query engine has no idea what metadata is. It does not really make any attempt to preserve it.
Sometimes users are doing something like rewriting a file with a different chunk size or repartitioning a dataset. In this case it can sometimes make sense to persist the origin metadata. However, I think the best solution for that is to reattach the metadata after it has gone through the query engine. The write/sink nodes should have options to attach custom metadata. We can expand on these as needed.
In ARROW-16607 there are some changes to metadata handling in the
arrow_dplyr_query
. With extension type support, more column types (like sf::sfc) can be supported, and with growing support for column types comes a greater chance that our current metadata restoration by default policy will cause difficult-to-work-around errors. The latest one I have run across is this one:This causes an error because the restored class has assumptions about the contents of the data frame that we can't necessarily know about (or would have to hard code for every data frame subclass).
I can see why
arrow::write_parquet()
andarrow::read_parquet()
(and feather, ipc_stream) might want to do this to faithfully roundtrip a data frame, and because the write/read roundtrip (usually) involves the same columns and the same rows, it's probably safe to restore metadata by default.The query engine does a lot of transformations that can break assumptions like the one I've shown above (where sf expects a certain column to exist and errors otherwise in a way that the user can't work around). Rather than hard-code the assumptions of every data.frame and vector subclass, I wonder if ignoring the R metadata for query engine output would be a better strategy. If it's not the default, it would be nice to provide an escape hatch for users or developers that find themselves in this position with no workaround.
With the addition of the vctrs extension type, there is a route to preserve attributes through the query engine (although it's a bit verbose). We could make it easier to do (e.g., by interpreting
I()
orrlang::box()
in some way).Reporter: Dewey Dunnington / @paleolimbot
Note: This issue was originally created as ARROW-16670. Please see the migration documentation for further details.