nealrichardson commented on a change in pull request #11361:
URL: https://github.com/apache/arrow/pull/11361#discussion_r724997032
##########
File path: r/R/metadata.R
##########
@@ -142,6 +142,21 @@ arrow_attributes <- function(x, only_top_level = FALSE) {
}
columns <- NULL
+
+ # Check if there are any columns that look like sf columns, warn that we will
+ # not be saving this data for now (but only if
arrow.preserve_row_level_metadata
+ # is set to FALSE)
+ possible_sf_col <- inherits(x, c("sfc", "sf"))
+ if (!getOption("arrow.preserve_row_level_metadata", FALSE) &&
possible_sf_col) {
+ warning(
+ "One of the columns given appears to be an `sfc` SF column. Due to their
unique ",
+ "nature, these columns do not convert to Arrow well. We are working on ",
+ "better ways to do this, but in the interim we recommend converting any
`sfc` ",
+ "columns to WKB (well-known binary) columns before using them with
Arrow.",
Review comment:
Can you suggest a function in `sf` that does this?
##########
File path: r/R/metadata.R
##########
@@ -142,6 +142,21 @@ arrow_attributes <- function(x, only_top_level = FALSE) {
}
columns <- NULL
+
+ # Check if there are any columns that look like sf columns, warn that we will
+ # not be saving this data for now (but only if
arrow.preserve_row_level_metadata
+ # is set to FALSE)
+ possible_sf_col <- inherits(x, c("sfc", "sf"))
+ if (!getOption("arrow.preserve_row_level_metadata", FALSE) &&
possible_sf_col) {
+ warning(
+ "One of the columns given appears to be an `sfc` SF column. Due to their
unique ",
+ "nature, these columns do not convert to Arrow well. We are working on ",
+ "better ways to do this, but in the interim we recommend converting any
`sfc` ",
+ "columns to WKB (well-known binary) columns before using them with
Arrow.",
+ call. = FALSE
+ )
+ }
+
attempt_to_save_row_level <- getOption("arrow.preserve_row_level_metadata",
FALSE) &&
is.list(x) && !inherits(x, "POSIXlt")
if (attempt_to_save_row_level) {
Review comment:
You could move the warning to an `else if (inherits(x, c("sfc", "sf")))`
below this, maybe that removes the complexity warning? Though maybe we should
warn regardless of whether we're saving the metadata, just a different warning?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]