jayzhan211 commented on code in PR #10790: URL: https://github.com/apache/datafusion/pull/10790#discussion_r1988208502
########## datafusion/functions-array/src/set_ops.rs: ########## @@ -259,6 +259,17 @@ fn generic_set_lists<OffsetSize: OffsetSizeTrait>( return general_array_distinct::<OffsetSize>(l, &field); } + // Handle empty array at rhs case + // array_union(arr, []) -> arr; + // array_intersect(arr, []) -> []; + if r.value_length(0).is_zero() { + if set_op == SetOp::Union { + return Ok(Arc::new(l.clone()) as ArrayRef); + } else { + return Ok(Arc::new(r.clone()) as ArrayRef); + } + } Review Comment: Let's find such query first, since the case what you mentioned might be handled already before enter to this line ########## datafusion/functions-array/src/set_ops.rs: ########## @@ -259,6 +259,17 @@ fn generic_set_lists<OffsetSize: OffsetSizeTrait>( return general_array_distinct::<OffsetSize>(l, &field); } + // Handle empty array at rhs case + // array_union(arr, []) -> arr; + // array_intersect(arr, []) -> []; + if r.value_length(0).is_zero() { + if set_op == SetOp::Union { + return Ok(Arc::new(l.clone()) as ArrayRef); + } else { + return Ok(Arc::new(r.clone()) as ArrayRef); + } + } Review Comment: Let's find such query first, since the case you mentioned might be handled already before enter to this line -- 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...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org