izveigor commented on code in PR #6384:
URL: https://github.com/apache/arrow-datafusion/pull/6384#discussion_r1209544990
##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -115,3 +149,1560 @@ pub fn array(values: &[ColumnarValue]) ->
Result<ColumnarValue> {
.collect();
Ok(ColumnarValue::Array(array_array(arrays.as_slice())?))
}
+
+macro_rules! downcast_arg {
+ ($ARG:expr, $ARRAY_TYPE:ident) => {{
+ $ARG.as_any().downcast_ref::<$ARRAY_TYPE>().ok_or_else(|| {
+ DataFusionError::Internal(format!(
+ "could not cast to {}",
+ type_name::<$ARRAY_TYPE>()
+ ))
+ })?
+ }};
+}
+
+macro_rules! append {
+ ($ARRAY:expr, $ELEMENT:expr, $ARRAY_TYPE:ident) => {{
+ let child_array =
+ downcast_arg!(downcast_arg!($ARRAY, ListArray).values(),
$ARRAY_TYPE);
+ let element = downcast_arg!($ELEMENT, $ARRAY_TYPE);
+ let concat = compute::concat(&[child_array, element])?;
+ let mut scalars = vec![];
+ for i in 0..concat.len() {
+ scalars.push(ColumnarValue::Scalar(ScalarValue::try_from_array(
+ &concat, i,
+ )?));
+ }
+ scalars
+ }};
+}
+
+/// Array_append SQL function
+pub fn array_append(args: &[ColumnarValue]) -> Result<ColumnarValue> {
Review Comment:
Should each function accept `&[ColumnarValue]` or `ArrayRef`? Is there a
difference in these approaches?
--
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]