diff --git a/src/expr/macro/src/gen.rs b/src/expr/macro/src/gen.rs index cf11f3422ec26..59c344d775e0b 100644 --- a/src/expr/macro/src/gen.rs +++ b/src/expr/macro/src/gen.rs @@ -70,6 +70,10 @@ impl FunctionAttr { // infer as the type of "anyarray" argument return Ok(quote! { |args| Ok(args[#i].clone()) }); } + if let Some(i) = self.args.iter().position(|t| t == "any") { + // infer as the array type of "any" argument + return Ok(quote! { |args| Ok(DataType::List(Box::new(args[#i].clone()))) }); + } } else if self.ret == "struct" { if let Some(i) = self.args.iter().position(|t| t == "struct") { // infer as the type of "struct" argument diff --git a/src/expr/src/agg/array_agg.rs b/src/expr/src/agg/array_agg.rs index d2569e8c06c9f..a6cfe02a31c11 100644 --- a/src/expr/src/agg/array_agg.rs +++ b/src/expr/src/agg/array_agg.rs @@ -16,10 +16,7 @@ use risingwave_common::array::ListValue; use risingwave_common::types::{Datum, ScalarRefImpl, ToOwnedDatum}; use risingwave_expr_macro::aggregate; -#[aggregate( - "array_agg(any) -> anyarray", - type_infer = "|args| Ok(DataType::List(Box::new(args[0].clone())))" -)] +#[aggregate("array_agg(any) -> anyarray")] fn array_agg(state: Option, value: Option>) -> ListValue { let mut state: Vec = state.unwrap_or_default().into(); state.push(value.to_owned_datum());