diff --git a/src/query/functions/src/scalars/array.rs b/src/query/functions/src/scalars/array.rs index 6d9366c4ddd5..d7032ec78661 100644 --- a/src/query/functions/src/scalars/array.rs +++ b/src/query/functions/src/scalars/array.rs @@ -98,7 +98,7 @@ const ARRAY_SORT_FUNCTIONS: &[(&str, (bool, bool)); 4] = &[ pub fn register(registry: &mut FunctionRegistry) { registry.register_aliases("contains", &["array_contains"]); registry.register_aliases("get", &["array_get"]); - registry.register_aliases("length", &["array_length"]); + registry.register_aliases("length", &["array_length", "array_size"]); registry.register_aliases("slice", &["array_slice"]); register_array_aggr(registry); diff --git a/src/query/functions/tests/it/scalars/array.rs b/src/query/functions/tests/it/scalars/array.rs index edc1c8c3093d..216c6d24c46f 100644 --- a/src/query/functions/tests/it/scalars/array.rs +++ b/src/query/functions/tests/it/scalars/array.rs @@ -73,6 +73,8 @@ fn test_length(file: &mut impl Write) { run_ast(file, "length([1, 2, 3])", &[]); run_ast(file, "length([true, false])", &[]); run_ast(file, "length(['a', 'b', 'c', 'd'])", &[]); + run_ast(file, "array_size(['a', 'b', 'c', 'd'])", &[]); + run_ast(file, "array_length(['a', 'b', 'c', 'd'])", &[]); } fn test_range(file: &mut impl Write) { diff --git a/src/query/functions/tests/it/scalars/testdata/array.txt b/src/query/functions/tests/it/scalars/testdata/array.txt index 2d8f5c79ff65..5fe69a9a48ca 100644 --- a/src/query/functions/tests/it/scalars/testdata/array.txt +++ b/src/query/functions/tests/it/scalars/testdata/array.txt @@ -100,6 +100,24 @@ output domain : {4..=4} output : 4 +ast : array_size(['a', 'b', 'c', 'd']) +raw expr : array_size(array('a', 'b', 'c', 'd')) +checked expr : length(array("a", "b", "c", "d")) +optimized expr : 4_u64 +output type : UInt64 +output domain : {4..=4} +output : 4 + + +ast : array_length(['a', 'b', 'c', 'd']) +raw expr : array_length(array('a', 'b', 'c', 'd')) +checked expr : length(array("a", "b", "c", "d")) +optimized expr : 4_u64 +output type : UInt64 +output domain : {4..=4} +output : 4 + + ast : range(10, 20) raw expr : range(10, 20) checked expr : range(to_uint64(10_u8), to_uint64(20_u8)) diff --git a/src/query/functions/tests/it/scalars/testdata/function_list.txt b/src/query/functions/tests/it/scalars/testdata/function_list.txt index d14e8fd8697c..508e13be229a 100644 --- a/src/query/functions/tests/it/scalars/testdata/function_list.txt +++ b/src/query/functions/tests/it/scalars/testdata/function_list.txt @@ -3,6 +3,7 @@ add -> plus array_contains -> contains array_get -> get array_length -> length +array_size -> length array_slice -> slice bitmap_and_not -> bitmap_not bitmap_cardinality -> bitmap_count diff --git a/tests/sqllogictests/suites/query/functions/02_0061_function_array.test b/tests/sqllogictests/suites/query/functions/02_0061_function_array.test index 0b340c991168..701fd718a8ea 100644 --- a/tests/sqllogictests/suites/query/functions/02_0061_function_array.test +++ b/tests/sqllogictests/suites/query/functions/02_0061_function_array.test @@ -29,6 +29,16 @@ select length(col1), length(col2), length(col3), length(col4) from t ---- 4 4 1 1 +query II +select array_length(col1), array_length(col2) from t +---- +4 4 + +query II +select array_size(col3), array_size(col4) from t +---- +1 1 + query ITT select get(col1, index - 7), get(col2, index - 8), get(col3, index - 9) from t ---- @@ -309,6 +319,11 @@ select length(col1), length(col2), length(col3), length(col4) from t ---- 4 4 1 1 +query IIII +select array_size(col1), array_size(col2), array_length(col3), array_length(col4) from t1 +---- +3 3 3 3 + statement ok DROP TABLE IF EXISTS t2