Apache DataFusion SQL Query Engine
Port `ArrayResize` to `functions-array` subcrate (#9570)
Eren Avsarogullari9d0c05b9c2e5
diff --git a/datafusion/expr/src/built_in_function.rs b/datafusion/expr/src/built_in_function.rsindex 3bb004d6f5..cf39a244c8 100644--- a/datafusion/expr/src/built_in_function.rs+++ b/datafusion/expr/src/built_in_function.rs@@ -136,8 +136,6 @@ pub enum BuiltinScalarFunction {ArrayUnion,/// array_exceptArrayExcept,- /// array_resize- ArrayResize,// string functions/// ascii@@ -311,7 +309,6 @@ impl BuiltinScalarFunction {BuiltinScalarFunction::ArraySlice => Volatility::Immutable,BuiltinScalarFunction::ArrayIntersect => Volatility::Immutable,BuiltinScalarFunction::ArrayUnion => Volatility::Immutable,- BuiltinScalarFunction::ArrayResize => Volatility::Immutable,BuiltinScalarFunction::Ascii => Volatility::Immutable,BuiltinScalarFunction::BitLength => Volatility::Immutable,BuiltinScalarFunction::Btrim => Volatility::Immutable,@@ -393,7 +390,6 @@ impl BuiltinScalarFunction {BuiltinScalarFunction::ArrayReplaceAll => Ok(input_expr_types[0].clone()),BuiltinScalarFunction::ArrayReverse => Ok(input_expr_types[0].clone()),BuiltinScalarFunction::ArraySlice => Ok(input_expr_types[0].clone()),- BuiltinScalarFunction::ArrayResize => Ok(input_expr_types[0].clone()),BuiltinScalarFunction::ArrayIntersect => {match (input_expr_types[0].clone(), input_expr_types[1].clone()) {(DataType::Null, DataType::Null) | (DataType::Null, _) => {@@ -608,9 +604,6 @@ impl BuiltinScalarFunction {BuiltinScalarFunction::ArrayIntersect => Signature::any(2, self.volatility()),BuiltinScalarFunction::ArrayUnion => Signature::any(2, self.volatility()),- BuiltinScalarFunction::ArrayResize => {- Signature::variadic_any(self.volatility())- }BuiltinScalarFunction::Concat| BuiltinScalarFunction::ConcatWithSeparator => {@@ -990,7 +983,6 @@ impl BuiltinScalarFunction {BuiltinScalarFunction::ArrayReverse => &["array_reverse", "list_reverse"],BuiltinScalarFunction::ArraySlice => &["array_slice", "list_slice"],BuiltinScalarFunction::ArrayUnion => &["array_union", "list_union"],- BuiltinScalarFunction::ArrayResize => &["array_resize", "list_resize"],BuiltinScalarFunction::ArrayIntersect => {&["array_intersect", "list_intersect"]}diff --git a/datafusion/expr/src/expr_fn.rs b/datafusion/expr/src/expr_fn.rsindex b0b9056e52..f35b663edf 100644--- a/datafusion/expr/src/expr_fn.rs+++ b/datafusion/expr/src/expr_fn.rs@@ -672,13 +672,6 @@ scalar_expr!();scalar_expr!(ArrayUnion, array_union, array1 array2, "returns an array of the elements in the union of array1 and array2 without duplicates.");-scalar_expr!(- ArrayResize,- array_resize,- array size value,- "returns an array with the specified size filled with the given value."-);-scalar_expr!(ArrayIntersect,array_intersect,diff --git a/datafusion/functions-array/src/kernels.rs b/datafusion/functions-array/src/kernels.rsindex 1a6ebdd902..df35a9c29b 100644--- a/datafusion/functions-array/src/kernels.rs+++ b/datafusion/functions-array/src/kernels.rs@@ -29,7 +29,7 @@ use arrow::datatypes::{};use arrow::row::{RowConverter, SortField};use arrow_array::new_null_array;-use arrow_buffer::{BooleanBufferBuilder, NullBuffer, OffsetBuffer};+use arrow_buffer::{ArrowNativeType, BooleanBufferBuilder, NullBuffer, OffsetBuffer};use arrow_schema::FieldRef;use arrow_schema::SortOptions;@@ -39,9 +39,11 @@ use datafusion_common::cast::{as_string_array,};use datafusion_common::{- exec_err, internal_err, not_impl_datafusion_err, DataFusionError, Result,+ exec_err, internal_datafusion_err, internal_err, not_impl_datafusion_err,+ DataFusionError, Result, ScalarValue,};use itertools::Itertools;+use std::any::type_name;use std::sync::Arc;@@ -893,6 +895,100 @@ pub fn array_length(args: &[ArrayRef]) -> Result<ArrayRef> {}}+/// array_resize SQL function+pub fn array_resize(arg: &[ArrayRef]) -> Result<ArrayRef> {+ if arg.len() < 2 || arg.len() > 3 {+ return exec_err!("array_resize needs two or three arguments");+ }++ let new_len = as_int64_array(&arg[1])?;+ let new_element = if arg.len() == 3 {+ Some(arg[2].clone())+ } else {+ None+ };++ match &arg[0].data_type() {+ DataType::List(field) => {+ let array = as_list_array(&arg[0])?;+ general_list_resize::<i32>(array, new_len, field, new_element)+ }+ DataType::LargeList(field) => {+ let array = as_large_list_array(&arg[0])?;+ general_list_resize::<i64>(array, new_len, field, new_element)+ }+ array_type => exec_err!("array_resize does not support type '{array_type:?}'."),+ }+}++/// array_resize keep the original array and append the default element to the end+fn general_list_resize<O: OffsetSizeTrait>(+ array: &GenericListArray<O>,+ count_array: &Int64Array,+ field: &FieldRef,+ default_element: Option<ArrayRef>,+) -> Result<ArrayRef>+where+ O: TryInto<i64>,+{+ let data_type = array.value_type();++ let values = array.values();+ let original_data = values.to_data();++ // create default element array+ let default_element = if let Some(default_element) = default_element {+ default_element+ } else {+ let null_scalar = ScalarValue::try_from(&data_type)?;+ null_scalar.to_array_of_size(original_data.len())?+ };+ let default_value_data = default_element.to_data();++ // create a mutable array to store the original data+ let capacity = Capacities::Array(original_data.len() + default_value_data.len());+ let mut offsets = vec![O::usize_as(0)];+ let mut mutable = MutableArrayData::with_capacities(+ vec![&original_data, &default_value_data],+ false,+ capacity,+ );++ for (row_index, offset_window) in array.offsets().windows(2).enumerate() {+ let count = count_array.value(row_index).to_usize().ok_or_else(|| {+ internal_datafusion_err!("array_resize: failed to convert size to usize")+ })?;+ let count = O::usize_as(count);+ let start = offset_window[0];+ if start + count > offset_window[1] {+ let extra_count =+ (start + count - offset_window[1]).try_into().map_err(|_| {+ internal_datafusion_err!(+ "array_resize: failed to convert size to i64"+ )+ })?;+ let end = offset_window[1];+ mutable.extend(0, (start).to_usize().unwrap(), (end).to_usize().unwrap());+ // append default element+ for _ in 0..extra_count {+ mutable.extend(1, row_index, row_index + 1);+ }+ } else {+ let end = start + count;+ mutable.extend(0, (start).to_usize().unwrap(), (end).to_usize().unwrap());+ };+ offsets.push(offsets[row_index] + count);+ }++ let data = mutable.freeze();+ Ok(Arc::new(GenericListArray::<O>::try_new(+ field.clone(),+ OffsetBuffer::<O>::new(offsets.into()),+ arrow_array::make_array(data),+ None,+ )?))+}+/// Array_sort SQL functionpub fn array_sort(args: &[ArrayRef]) -> Result<ArrayRef> {if args.is_empty() || args.len() > 3 {diff --git a/datafusion/functions-array/src/lib.rs b/datafusion/functions-array/src/lib.rsindex a932e7d7a5..944cc820ac 100644--- a/datafusion/functions-array/src/lib.rs+++ b/datafusion/functions-array/src/lib.rs@@ -57,6 +57,7 @@ pub mod expr_fn {pub use super::udf::array_length;pub use super::udf::array_ndims;pub use super::udf::array_repeat;+ pub use super::udf::array_resize;pub use super::udf::array_sort;pub use super::udf::array_to_string;pub use super::udf::cardinality;@@ -89,6 +90,7 @@ pub fn register_all(registry: &mut dyn FunctionRegistry) -> Result<()> {udf::array_sort_udf(),udf::array_distinct_udf(),udf::array_repeat_udf(),+ udf::array_resize_udf(),];functions.into_iter().try_for_each(|udf| {let existing_udf = registry.register_udf(udf)?;diff --git a/datafusion/functions-array/src/udf.rs b/datafusion/functions-array/src/udf.rsindex 9fd9e0309b..0e0efa185f 100644--- a/datafusion/functions-array/src/udf.rs+++ b/datafusion/functions-array/src/udf.rs@@ -427,6 +427,62 @@ impl ScalarUDFImpl for ArraySort {}}+make_udf_function!(+ ArrayResize,+ array_resize,+ array size value,+ "returns an array with the specified size filled with the given value.",+ array_resize_udf+);++#[derive(Debug)]+pub(super) struct ArrayResize {+ signature: Signature,+ aliases: Vec<String>,+}++impl ArrayResize {+ pub fn new() -> Self {+ Self {+ signature: Signature::variadic_any(Volatility::Immutable),+ aliases: vec!["array_resize".to_string(), "list_resize".to_string()],+ }+ }+}++impl ScalarUDFImpl for ArrayResize {+ fn as_any(&self) -> &dyn Any {+ self+ }+ fn name(&self) -> &str {+ "array_resize"+ }++ fn signature(&self) -> &Signature {+ &self.signature+ }++ fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {+ use DataType::*;+ match &arg_types[0] {+ List(field) | FixedSizeList(field, _) => Ok(List(field.clone())),+ LargeList(field) => Ok(LargeList(field.clone())),+ _ => exec_err!(+ "Not reachable, data_type should be List, LargeList or FixedSizeList"+ ),+ }+ }++ fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {+ let args = ColumnarValue::values_to_arrays(args)?;+ crate::kernels::array_resize(&args).map(ColumnarValue::Array)+ }++ fn aliases(&self) -> &[String] {+ &self.aliases+ }+}+make_udf_function!(Cardinality,cardinality,diff --git a/datafusion/physical-expr/src/array_expressions.rs b/datafusion/physical-expr/src/array_expressions.rsindex c846674e75..3bad9347e1 100644--- a/datafusion/physical-expr/src/array_expressions.rs+++ b/datafusion/physical-expr/src/array_expressions.rs@@ -26,7 +26,7 @@ use arrow::buffer::OffsetBuffer;use arrow::compute::{self};use arrow::datatypes::{DataType, Field, UInt64Type};use arrow::row::{RowConverter, SortField};-use arrow_buffer::{ArrowNativeType, NullBuffer};+use arrow_buffer::NullBuffer;use arrow_schema::FieldRef;use datafusion_common::cast::{@@ -35,7 +35,6 @@ use datafusion_common::cast::{use datafusion_common::utils::array_into_list_array;use datafusion_common::{exec_err, internal_datafusion_err, internal_err, plan_err, DataFusionError, Result,- ScalarValue,};use itertools::Itertools;@@ -1393,100 +1392,6 @@ pub fn general_array_distinct<OffsetSize: OffsetSizeTrait>()?))}-/// array_resize SQL function-pub fn array_resize(arg: &[ArrayRef]) -> Result<ArrayRef> {- if arg.len() < 2 || arg.len() > 3 {- return exec_err!("array_resize needs two or three arguments");- }-- let new_len = as_int64_array(&arg[1])?;- let new_element = if arg.len() == 3 {- Some(arg[2].clone())- } else {- None- };-- match &arg[0].data_type() {- DataType::List(field) => {- let array = as_list_array(&arg[0])?;- general_list_resize::<i32>(array, new_len, field, new_element)- }- DataType::LargeList(field) => {- let array = as_large_list_array(&arg[0])?;- general_list_resize::<i64>(array, new_len, field, new_element)- }- array_type => exec_err!("array_resize does not support type '{array_type:?}'."),- }-}--/// array_resize keep the original array and append the default element to the end-fn general_list_resize<O: OffsetSizeTrait>(- array: &GenericListArray<O>,- count_array: &Int64Array,- field: &FieldRef,- default_element: Option<ArrayRef>,-) -> Result<ArrayRef>-where- O: TryInto<i64>,-{- let data_type = array.value_type();-- let values = array.values();- let original_data = values.to_data();-- // create default element array- let default_element = if let Some(default_element) = default_element {- default_element- } else {- let null_scalar = ScalarValue::try_from(&data_type)?;- null_scalar.to_array_of_size(original_data.len())?- };- let default_value_data = default_element.to_data();-- // create a mutable array to store the original data- let capacity = Capacities::Array(original_data.len() + default_value_data.len());- let mut offsets = vec![O::usize_as(0)];- let mut mutable = MutableArrayData::with_capacities(- vec![&original_data, &default_value_data],- false,- capacity,- );-- for (row_index, offset_window) in array.offsets().windows(2).enumerate() {- let count = count_array.value(row_index).to_usize().ok_or_else(|| {- internal_datafusion_err!("array_resize: failed to convert size to usize")- })?;- let count = O::usize_as(count);- let start = offset_window[0];- if start + count > offset_window[1] {- let extra_count =- (start + count - offset_window[1]).try_into().map_err(|_| {- internal_datafusion_err!(- "array_resize: failed to convert size to i64"- )- })?;- let end = offset_window[1];- mutable.extend(0, (start).to_usize().unwrap(), (end).to_usize().unwrap());- // append default element- for _ in 0..extra_count {- mutable.extend(1, row_index, row_index + 1);- }- } else {- let end = start + count;- mutable.extend(0, (start).to_usize().unwrap(), (end).to_usize().unwrap());- };- offsets.push(offsets[row_index] + count);- }-- let data = mutable.freeze();- Ok(Arc::new(GenericListArray::<O>::try_new(- field.clone(),- OffsetBuffer::<O>::new(offsets.into()),- arrow_array::make_array(data),- None,- )?))-}-/// array_reverse SQL functionpub fn array_reverse(arg: &[ArrayRef]) -> Result<ArrayRef> {if arg.len() != 1 {diff --git a/datafusion/physical-expr/src/functions.rs b/datafusion/physical-expr/src/functions.rsindex ff653192c0..6da3980fed 100644--- a/datafusion/physical-expr/src/functions.rs+++ b/datafusion/physical-expr/src/functions.rs@@ -300,9 +300,6 @@ pub fn create_physical_fun(BuiltinScalarFunction::ArrayIntersect => Arc::new(|args| {make_scalar_function_inner(array_expressions::array_intersect)(args)}),- BuiltinScalarFunction::ArrayResize => Arc::new(|args| {- make_scalar_function_inner(array_expressions::array_resize)(args)- }),BuiltinScalarFunction::ArrayUnion => Arc::new(|args| {make_scalar_function_inner(array_expressions::array_union)(args)}),diff --git a/datafusion/proto/proto/datafusion.proto b/datafusion/proto/proto/datafusion.protoindex b5683dc142..c9e4e0d64e 100644--- a/datafusion/proto/proto/datafusion.proto+++ b/datafusion/proto/proto/datafusion.proto@@ -669,7 +669,7 @@ enum ScalarFunction {FindInSet = 127;/// 128 was ArraySort/// 129 was ArrayDistinct- ArrayResize = 130;+ /// 130 was ArrayResizeEndsWith = 131;/// 132 was InStrMakeDate = 133;diff --git a/datafusion/proto/src/generated/pbjson.rs b/datafusion/proto/src/generated/pbjson.rsindex f5be49dc9d..e3e1ee966b 100644--- a/datafusion/proto/src/generated/pbjson.rs+++ b/datafusion/proto/src/generated/pbjson.rs@@ -22973,7 +22973,6 @@ impl serde::Serialize for ScalarFunction {Self::Levenshtein => "Levenshtein",Self::SubstrIndex => "SubstrIndex",Self::FindInSet => "FindInSet",- Self::ArrayResize => "ArrayResize",Self::EndsWith => "EndsWith",Self::MakeDate => "MakeDate",Self::ArrayReverse => "ArrayReverse",@@ -23070,7 +23069,6 @@ impl<'de> serde::Deserialize<'de> for ScalarFunction {"Levenshtein","SubstrIndex","FindInSet",- "ArrayResize","EndsWith","MakeDate","ArrayReverse",@@ -23196,7 +23194,6 @@ impl<'de> serde::Deserialize<'de> for ScalarFunction {"Levenshtein" => Ok(ScalarFunction::Levenshtein),"SubstrIndex" => Ok(ScalarFunction::SubstrIndex),"FindInSet" => Ok(ScalarFunction::FindInSet),- "ArrayResize" => Ok(ScalarFunction::ArrayResize),"EndsWith" => Ok(ScalarFunction::EndsWith),"MakeDate" => Ok(ScalarFunction::MakeDate),"ArrayReverse" => Ok(ScalarFunction::ArrayReverse),diff --git a/datafusion/proto/src/generated/prost.rs b/datafusion/proto/src/generated/prost.rsindex e1c9af105b..d7e1224043 100644--- a/datafusion/proto/src/generated/prost.rs+++ b/datafusion/proto/src/generated/prost.rs@@ -2942,7 +2942,7 @@ pub enum ScalarFunction {FindInSet = 127,/// / 128 was ArraySort/// / 129 was ArrayDistinct- ArrayResize = 130,+ /// / 130 was ArrayResizeEndsWith = 131,/// / 132 was InStrMakeDate = 133,@@ -3041,7 +3041,6 @@ impl ScalarFunction {ScalarFunction::Levenshtein => "Levenshtein",ScalarFunction::SubstrIndex => "SubstrIndex",ScalarFunction::FindInSet => "FindInSet",- ScalarFunction::ArrayResize => "ArrayResize",ScalarFunction::EndsWith => "EndsWith",ScalarFunction::MakeDate => "MakeDate",ScalarFunction::ArrayReverse => "ArrayReverse",@@ -3132,7 +3131,6 @@ impl ScalarFunction {"Levenshtein" => Some(Self::Levenshtein),"SubstrIndex" => Some(Self::SubstrIndex),"FindInSet" => Some(Self::FindInSet),- "ArrayResize" => Some(Self::ArrayResize),"EndsWith" => Some(Self::EndsWith),"MakeDate" => Some(Self::MakeDate),"ArrayReverse" => Some(Self::ArrayReverse),diff --git a/datafusion/proto/src/logical_plan/from_proto.rs b/datafusion/proto/src/logical_plan/from_proto.rsindex b229c1c699..024f16fd09 100644--- a/datafusion/proto/src/logical_plan/from_proto.rs+++ b/datafusion/proto/src/logical_plan/from_proto.rs@@ -49,10 +49,9 @@ use datafusion_expr::window_frame::{check_window_frame, regularize_window_order_use datafusion_expr::{acosh, array_element, array_except, array_intersect, array_pop_back, array_pop_front,array_position, array_positions, array_remove, array_remove_all, array_remove_n,- array_replace, array_replace_all, array_replace_n, array_resize, array_slice,- array_union, ascii, asinh, atan, atan2, atanh, bit_length, btrim, cbrt, ceil,- character_length, chr, coalesce, concat_expr, concat_ws_expr, cos, cosh, cot,- degrees, ends_with, exp,+ array_replace, array_replace_all, array_replace_n, array_slice, array_union, ascii,+ asinh, atan, atan2, atanh, bit_length, btrim, cbrt, ceil, character_length, chr,+ coalesce, concat_expr, concat_ws_expr, cos, cosh, cot, degrees, ends_with, exp,expr::{self, InList, Sort, WindowFunction},factorial, find_in_set, floor, gcd, initcap, iszero, lcm, left, levenshtein, ln, log,log10, log2,@@ -488,7 +487,6 @@ impl From<&protobuf::ScalarFunction> for BuiltinScalarFunction {ScalarFunction::ArraySlice => Self::ArraySlice,ScalarFunction::ArrayIntersect => Self::ArrayIntersect,ScalarFunction::ArrayUnion => Self::ArrayUnion,- ScalarFunction::ArrayResize => Self::ArrayResize,ScalarFunction::Log2 => Self::Log2,ScalarFunction::Signum => Self::Signum,ScalarFunction::Ascii => Self::Ascii,@@ -1453,11 +1451,6 @@ pub fn parse_expr(parse_expr(&args[0], registry, codec)?,parse_expr(&args[1], registry, codec)?,)),- ScalarFunction::ArrayResize => Ok(array_resize(- parse_expr(&args[0], registry, codec)?,- parse_expr(&args[1], registry, codec)?,- parse_expr(&args[2], registry, codec)?,- )),ScalarFunction::Sqrt => Ok(sqrt(parse_expr(&args[0], registry, codec)?)),ScalarFunction::Cbrt => Ok(cbrt(parse_expr(&args[0], registry, codec)?)),ScalarFunction::Sin => Ok(sin(parse_expr(&args[0], registry, codec)?)),diff --git a/datafusion/proto/src/logical_plan/to_proto.rs b/datafusion/proto/src/logical_plan/to_proto.rsindex 40f195c9f1..e492b96577 100644--- a/datafusion/proto/src/logical_plan/to_proto.rs+++ b/datafusion/proto/src/logical_plan/to_proto.rs@@ -1460,7 +1460,6 @@ impl TryFrom<&BuiltinScalarFunction> for protobuf::ScalarFunction {BuiltinScalarFunction::ArrayPopBack => Self::ArrayPopBack,BuiltinScalarFunction::ArrayPosition => Self::ArrayPosition,BuiltinScalarFunction::ArrayPositions => Self::ArrayPositions,- BuiltinScalarFunction::ArrayResize => Self::ArrayResize,BuiltinScalarFunction::ArrayRemove => Self::ArrayRemove,BuiltinScalarFunction::ArrayRemoveN => Self::ArrayRemoveN,BuiltinScalarFunction::ArrayRemoveAll => Self::ArrayRemoveAll,diff --git a/datafusion/proto/tests/cases/roundtrip_logical_plan.rs b/datafusion/proto/tests/cases/roundtrip_logical_plan.rsindex 2c8cf07e9e..9bf68105f4 100644--- a/datafusion/proto/tests/cases/roundtrip_logical_plan.rs+++ b/datafusion/proto/tests/cases/roundtrip_logical_plan.rs@@ -566,6 +566,7 @@ async fn roundtrip_expr_api() -> Result<()> {lit("NULLS LAST"),),array_distinct(make_array(vec![lit(1), lit(3), lit(3), lit(2), lit(2)])),+ array_resize(make_array(vec![lit(1), lit(2), lit(3)]), lit(5), lit(0)),];// ensure expressions created with the expr api can be round trippeddiff --git a/docs/source/user-guide/expressions.md b/docs/source/user-guide/expressions.mdindex 05eb063c3d..8a1d822143 100644--- a/docs/source/user-guide/expressions.md+++ b/docs/source/user-guide/expressions.md@@ -238,7 +238,7 @@ select log(-1), log(0), sqrt(-1);| array_intersect(array1, array2) | Returns an array of the elements in the intersection of array1 and array2. `array_intersect([1, 2, 3, 4], [5, 6, 3, 4]) -> [3, 4]` || array_union(array1, array2) | Returns an array of the elements in the union of array1 and array2 without duplicates. `array_union([1, 2, 3, 4], [5, 6, 3, 4]) -> [1, 2, 3, 4, 5, 6]` || array_except(array1, array2) | Returns an array of the elements that appear in the first array but not in the second. `array_except([1, 2, 3, 4], [5, 6, 3, 4]) -> [3, 4]` |-| array_resize(array, size, value) | Resizes the list to contain size elements. Initializes new elements with value or empty if value is not set. `array_resize([1, 2, 3], 5, 0) -> [1, 2, 3, 4, 5, 6]` |+| array_resize(array, size, value) | Resizes the list to contain size elements. Initializes new elements with value or empty if value is not set. `array_resize([1, 2, 3], 5, 0) -> [1, 2, 3, 0, 0]` || array_sort(array, desc, null_first) | Returns sorted array. `array_sort([3, 1, 2, 5, 4]) -> [1, 2, 3, 4, 5]` || cardinality(array) | Returns the total number of elements in the array. `cardinality([[1, 2, 3], [4, 5, 6]]) -> 6` || make_array(value1, [value2 [, ...]]) | Returns an Arrow array using the specified input expressions. `make_array(1, 2, 3) -> [1, 2, 3]` |diff --git a/docs/source/user-guide/sql/scalar_functions.md b/docs/source/user-guide/sql/scalar_functions.mdindex 420de5f3fd..cb26472abb 100644--- a/docs/source/user-guide/sql/scalar_functions.md+++ b/docs/source/user-guide/sql/scalar_functions.md@@ -1969,6 +1969,7 @@ from_unixtime(expression)- [array_push_back](#array_push_back)- [array_push_front](#array_push_front)- [array_repeat](#array_repeat)+- [array_resize](#array_resize)- [array_remove](#array_remove)- [array_remove_n](#array_remove_n)- [array_remove_all](#array_remove_all)@@ -2006,6 +2007,7 @@ from_unixtime(expression)- [list_push_back](#list_push_back)- [list_push_front](#list_push_front)- [list_repeat](#list_repeat)+- [list_resize](#list_resize)- [list_remove](#list_remove)- [list_remove_n](#list_remove_n)- [list_remove_all](#list_remove_all)@@ -2082,6 +2084,36 @@ array_sort(array, desc, nulls_first)- list_sort+### `array_resize`++Resizes the list to contain size elements. Initializes new elements with value or empty if value is not set.++```+array_resize(array, size, value)+```++#### Arguments++- **array**: Array expression.+ Can be a constant, column, or function, and any combination of array operators.+- **size**: New size of given array.+- **value**: Defines new elements' value or empty if value is not set.++#### Example++```+❯ select array_resize([1, 2, 3], 5, 0);++-------------------------------------++| array_resize(List([1,2,3],5,0)) |++-------------------------------------++| [1, 2, 3, 0, 0] |++-------------------------------------++```++#### Aliases++- list_resize+### `array_cat`_Alias of [array_concat](#array_concat)._@@ -3071,6 +3103,10 @@ _Alias of [array_prepend](#array_prepend).__Alias of [array_repeat](#array_repeat)._+### `list_resize`++_Alias of [array_resize](#array_resize)._+### `list_remove`_Alias of [array_remove](#array_remove)._