nealrichardson commented on a change in pull request #10724: URL: https://github.com/apache/arrow/pull/10724#discussion_r671579494
########## File path: r/R/arrow-datum.R ########## @@ -47,10 +47,29 @@ is.infinite.ArrowDatum <- function(x) { } #' @export -is.na.ArrowDatum <- function(x) call_function("is_null", x) +is.na.ArrowDatum <- function(x) { + # TODO: if an option is added to the is_null kernel to treat NaN as NA, + # use that to simplify the code here (ARROW-13367) + if (x$type_id() %in% TYPES_WITH_NAN) { + call_function("is_nan", x) | call_function("is_null", x) + } else { + call_function("is_null", x) + } +} #' @export -is.nan.ArrowDatum <- function(x) call_function("is_nan", x) +is.nan.ArrowDatum <- function(x) { + if (x$type_id() %in% TYPES_WITH_NAN) { + # TODO: if an option is added to the is_nan kernel to treat NA as NaN, + # use that to simplify the code here (ARROW-13366) + call_function("is_nan", x) & call_function("is_valid", x) + } else { + # This is just a hacky way to return an ArrowDatum identical to the input + # in shape but with a Boolean value of false in every position. + # TODO: implement this more efficiently and elegantly if possible + call_function("is_valid", x) & call_function("is_null", x) Review comment: How about this? ```suggestion Scalar$create(FALSE)$as_array(length(x)) ``` -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org