diff --git a/src/expr/src/sig/mod.rs b/src/expr/src/sig/mod.rs index 6d7fa0d0514f3..cb719ac1e226e 100644 --- a/src/expr/src/sig/mod.rs +++ b/src/expr/src/sig/mod.rs @@ -165,6 +165,8 @@ impl FuncSign { if !self.match_number_of_args(args.len()) { return false; } + // allow `zip` as the length of `args` may be larger than `inputs_type` + #[allow(clippy::disallowed_methods)] self.inputs_type .iter() .zip(args.iter()) diff --git a/src/expr/src/vector_op/array_concat.rs b/src/expr/src/vector_op/array_concat.rs index 453c60caf5ea3..c74d763e28efa 100644 --- a/src/expr/src/vector_op/array_concat.rs +++ b/src/expr/src/vector_op/array_concat.rs @@ -155,7 +155,7 @@ fn array_cat( /// {NULL} /// ``` #[function("array_append(anyarray, any) -> anyarray")] -fn array_append<'a>(left: Option>, right: Option>) -> ListValue { +fn array_append(left: Option>, right: Option>) -> ListValue { ListValue::new( left.iter() .flat_map(|list| list.iter()) @@ -192,7 +192,7 @@ fn array_append<'a>(left: Option>, right: Option>) /// {NULL} /// ``` #[function("array_prepend(any, anyarray) -> anyarray")] -fn array_prepend<'a>(left: Option>, right: Option>) -> ListValue { +fn array_prepend(left: Option>, right: Option>) -> ListValue { ListValue::new( std::iter::once(left) .chain(right.iter().flat_map(|list| list.iter())) diff --git a/src/expr/src/vector_op/array_min_max.rs b/src/expr/src/vector_op/array_min_max.rs index b5ff4f008a412..90dcb2a5728f5 100644 --- a/src/expr/src/vector_op/array_min_max.rs +++ b/src/expr/src/vector_op/array_min_max.rs @@ -22,21 +22,8 @@ pub fn array_min(list: ListRef<'_>) -> Option> { min_value.map(|v| v.0) } -#[function("array_max(list) -> *int")] -#[function("array_max(list) -> *float")] -#[function("array_max(list) -> decimal")] -#[function("array_max(list) -> serial")] -#[function("array_max(list) -> int256")] -#[function("array_max(list) -> date")] -#[function("array_max(list) -> time")] -#[function("array_max(list) -> timestamp")] -#[function("array_max(list) -> timestamptz")] -#[function("array_max(list) -> varchar")] -#[function("array_max(list) -> bytea")] -pub fn array_max(list: ListRef<'_>) -> Result> { +#[function("array_max(anyarray) -> any")] +pub fn array_max(list: ListRef<'_>) -> Option> { let max_value = list.iter().flatten().map(DefaultOrdered).max(); - match max_value.map(|v| v.0).to_owned_datum() { - Some(s) => Ok(Some(s.try_into()?)), - None => Ok(None), - } + max_value.map(|v| v.0) } diff --git a/src/expr/src/vector_op/array_sort.rs b/src/expr/src/vector_op/array_sort.rs index 7ba455d6bbd61..b5ad13ab44ffb 100644 --- a/src/expr/src/vector_op/array_sort.rs +++ b/src/expr/src/vector_op/array_sort.rs @@ -13,19 +13,15 @@ // limitations under the License. use risingwave_common::array::*; -use risingwave_common::types::{Datum, DatumRef, DefaultOrdered, ToOwnedDatum}; +use risingwave_common::types::{DatumRef, DefaultOrdered, ToOwnedDatum}; use risingwave_expr_macro::function; -#[function("array_sort(list) -> list")] +#[function("array_sort(anyarray) -> anyarray")] pub fn array_sort(list: ListRef<'_>) -> ListValue { let mut v = list .iter() .map(DefaultOrdered) .collect::>>>(); v.sort(); - ListValue::new( - v.into_iter() - .map(|x| x.0.to_owned_datum()) - .collect::>(), - ) + ListValue::new(v.into_iter().map(|x| x.0.to_owned_datum()).collect()) } diff --git a/src/frontend/src/expr/type_inference/func.rs b/src/frontend/src/expr/type_inference/func.rs index a3f75b37a7c70..a11e08ab8bff1 100644 --- a/src/frontend/src/expr/type_inference/func.rs +++ b/src/frontend/src/expr/type_inference/func.rs @@ -99,10 +99,9 @@ pub fn infer_some_all( } if !matches!(&element_type, Some(e) if sig.inputs_type[1].matches(e)) { let SigDataType::Exact(t) = &sig.inputs_type[1] else { - return Err(ErrorCode::BindError( - "array/struct on left are not supported yet".into(), - ) - .into()); + return Err( + ErrorCode::BindError("array/struct on left are not supported yet".into()).into(), + ); }; inputs[1].cast_implicit_mut(DataType::List(Box::new(t.clone())))?; }