crepererum commented on code in PR #7313:
URL: https://github.com/apache/arrow-datafusion/pull/7313#discussion_r1299787026
##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -986,6 +986,22 @@ macro_rules! general_repeat_list {
}};
}
+/// Array_empty SQL function
+pub fn array_empty(args: &[ArrayRef]) -> Result<ArrayRef> {
+ let array = as_list_array(&args[0])?;
+ let builder = array
+ .iter()
+ .map(|arr| {
+ if let Some(arr) = arr {
+ Some(arr.is_empty())
+ } else {
+ Some(true)
Review Comment:
> Hi @crepererum , I do not fully understand your suggestion.
So your PR proposes that `array_empty(NULL)` is `TRUE` while I would argue
that `array_empty(NULL)` should yield `NULL` because this is how most SQL
functions work.
> Since we intend to have the same behavior as Clickhouse does for this
function, we can just return `true` for `null`.
I would argue that DataFusion should not necessarily copy weird / unexpected
behaviors of other vendors. @alamb what's your opinion here?
> Btw, not sure what `COALESCE` you mean.
This is a widely supported SQL method for "replace NULL w/ a default value",
see [postgres
docs](https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL).
--
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]