This is an automated email from the ASF dual-hosted git repository.
jianliangqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 526a66e9fb [Function](array-type) support array_apply (#17020)
526a66e9fb is described below
commit 526a66e9fb0ded1f597163f991ee6b2042d6de42
Author: lihangyu <[email protected]>
AuthorDate: Thu Feb 23 17:38:16 2023 +0800
[Function](array-type) support array_apply (#17020)
Filter array to match specific binary condition
```
mysql> select array_apply([1000000, 1000001, 1000002], '=', 1000002);
+-------------------------------------------------------------+
| array_apply(ARRAY(1000000, 1000001, 1000002), '=', 1000002) |
+-------------------------------------------------------------+
| [1000002] |
+-------------------------------------------------------------+
```
---
be/src/vec/CMakeLists.txt | 1 +
.../vec/functions/array/function_array_apply.cpp | 219 +++++++++++++++++++++
.../functions/array/function_array_register.cpp | 2 +
.../sql-functions/array-functions/array_apply.md | 81 ++++++++
.../sql-functions/array-functions/array_apply.md | 80 ++++++++
gensrc/script/doris_builtins_functions.py | 17 ++
.../test_array_functions_by_literal.out | 15 ++
.../array_functions/test_array_with_scale_type.out | 24 +++
.../test_array_functions_by_literal.groovy | 7 +
.../test_array_with_scale_type.groovy | 7 +
10 files changed, 453 insertions(+)
diff --git a/be/src/vec/CMakeLists.txt b/be/src/vec/CMakeLists.txt
index a57815f3d6..8f7babdcce 100644
--- a/be/src/vec/CMakeLists.txt
+++ b/be/src/vec/CMakeLists.txt
@@ -179,6 +179,7 @@ set(VEC_FILES
functions/array/function_array_popback.cpp
functions/array/function_array_constructor.cpp
functions/array/function_array_with_constant.cpp
+ functions/array/function_array_apply.cpp
exprs/table_function/vexplode_json_array.cpp
functions/math.cpp
functions/function_bitmap.cpp
diff --git a/be/src/vec/functions/array/function_array_apply.cpp
b/be/src/vec/functions/array/function_array_apply.cpp
new file mode 100644
index 0000000000..3cace60982
--- /dev/null
+++ b/be/src/vec/functions/array/function_array_apply.cpp
@@ -0,0 +1,219 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <vec/columns/column_array.h>
+#include <vec/columns/column_nullable.h>
+#include <vec/columns/columns_number.h>
+#include <vec/data_types/data_type_array.h>
+#include <vec/data_types/data_type_number.h>
+#include <vec/functions/function.h>
+#include <vec/functions/function_helpers.h>
+#include <vec/functions/simple_function_factory.h>
+
+namespace doris::vectorized {
+
+// array_apply([1, 2, 3, 10], ">=", 5) -> [10]
+// This function is temporary, use it to meet the requirement before
implementing the lambda function.
+class FunctionArrayApply : public IFunction {
+public:
+ static constexpr auto name = "array_apply";
+
+ static FunctionPtr create() { return
std::make_shared<FunctionArrayApply>(); }
+
+ String get_name() const override { return name; }
+
+ size_t get_number_of_arguments() const override { return 3; }
+
+ DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
+ DCHECK(is_array(arguments[0]))
+ << "first argument for function: " << name << " should be
DataTypeArray"
+ << " and arguments[0] is " << arguments[0]->get_name();
+ return arguments[0];
+ }
+
+ Status execute_impl(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
+ size_t result, size_t input_rows_count) override {
+ ColumnPtr src_column =
+
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+ const auto& src_column_array =
check_and_get_column<ColumnArray>(*src_column);
+ if (!src_column_array) {
+ return Status::RuntimeError(
+ fmt::format("unsupported types for function {}({})",
get_name(),
+
block.get_by_position(arguments[0]).type->get_name()));
+ }
+ const auto& src_offsets = src_column_array->get_offsets();
+ const auto* src_nested_column = &src_column_array->get_data();
+ DCHECK(src_nested_column != nullptr);
+
+ DataTypePtr src_column_type = block.get_by_position(arguments[0]).type;
+ auto nested_type = assert_cast<const
DataTypeArray&>(*src_column_type).get_nested_type();
+ const std::string& condition =
+
block.get_by_position(arguments[1]).column->get_data_at(0).to_string();
+ if (!is_column_const(*block.get_by_position(arguments[2]).column)) {
+ return Status::RuntimeError(
+ "execute failed or unsupported column, only support const
column");
+ }
+ const ColumnConst& rhs_value_column =
+ static_cast<const
ColumnConst&>(*block.get_by_position(arguments[2]).column.get());
+ ColumnPtr result_ptr;
+ RETURN_IF_ERROR(_execute(*src_nested_column, nested_type, src_offsets,
condition,
+ rhs_value_column, &result_ptr));
+ block.replace_by_position(result, std::move(result_ptr));
+ return Status::OK();
+ }
+
+private:
+ enum class ApplyOp {
+ UNKNOWN = 0,
+ EQ = 1,
+ NE = 2,
+ LT = 3,
+ LE = 4,
+ GT = 5,
+ GE = 6,
+ };
+ template <typename T, ApplyOp op>
+ bool apply(T data, T comp) {
+ if constexpr (op == ApplyOp::EQ) {
+ return data == comp;
+ }
+ if constexpr (op == ApplyOp::NE) {
+ return data != comp;
+ }
+ if constexpr (op == ApplyOp::LT) {
+ return data < comp;
+ }
+ if constexpr (op == ApplyOp::LE) {
+ return data <= comp;
+ }
+ if constexpr (op == ApplyOp::GT) {
+ return data > comp;
+ }
+ if constexpr (op == ApplyOp::GE) {
+ return data >= comp;
+ }
+ __builtin_unreachable();
+ }
+
+ template <typename T, ApplyOp op>
+ ColumnPtr _apply_internal(const IColumn& src_column, const
ColumnArray::Offsets64& src_offsets,
+ const ColumnConst& cmp) {
+ T rhs_val = *reinterpret_cast<const T*>(cmp.get_data_at(0).data);
+ auto column_filter = ColumnUInt8::create(src_column.size(), 0);
+ auto& column_filter_data = column_filter->get_data();
+ const char* src_column_data_ptr = nullptr;
+ if (!src_column.is_nullable()) {
+ src_column_data_ptr = src_column.get_raw_data().data;
+ } else {
+ src_column_data_ptr =
check_and_get_column<ColumnNullable>(src_column)
+ ->get_nested_column()
+ .get_raw_data()
+ .data;
+ }
+ for (size_t i = 0; i < src_column.size(); ++i) {
+ T lhs_val = *reinterpret_cast<const T*>(src_column_data_ptr);
+ if (apply<T, op>(lhs_val, rhs_val)) {
+ column_filter_data[i] = 1;
+ }
+ src_column_data_ptr += sizeof(T);
+ }
+ const IColumn::Filter& filter = column_filter_data;
+ ColumnPtr filtered = src_column.filter(filter, src_column.size());
+ auto column_offsets =
ColumnArray::ColumnOffsets::create(src_offsets.size());
+ ColumnArray::Offsets64& dst_offsets = column_offsets->get_data();
+ size_t in_pos = 0;
+ size_t out_pos = 0;
+ for (size_t i = 0; i < src_offsets.size(); ++i) {
+ for (; in_pos < src_offsets[i]; ++in_pos) {
+ if (filter[in_pos]) ++out_pos;
+ }
+ dst_offsets[i] = out_pos;
+ }
+ return ColumnArray::create(filtered, std::move(column_offsets));
+ }
+
+#define APPLY_ALL_TYPES(src_column, src_offsets, OP, cmp, dst)
\
+ do {
\
+ WhichDataType which(remove_nullable(nested_type));
\
+ if (which.is_uint8()) {
\
+ *dst = _apply_internal<UInt8, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_int8()) {
\
+ *dst = _apply_internal<Int8, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_int16()) {
\
+ *dst = _apply_internal<Int16, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_int32()) {
\
+ *dst = _apply_internal<Int32, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_int64()) {
\
+ *dst = _apply_internal<Int64, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_int128()) {
\
+ *dst = _apply_internal<Int128, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_float32()) {
\
+ *dst = _apply_internal<Float32, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_float64()) {
\
+ *dst = _apply_internal<Float64, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_date()) {
\
+ *dst = _apply_internal<Int64, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_date_time()) {
\
+ *dst = _apply_internal<Int64, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_date_v2()) {
\
+ *dst = _apply_internal<UInt32, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_date_time_v2()) {
\
+ *dst = _apply_internal<UInt64, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_date_time_v2()) {
\
+ *dst = _apply_internal<UInt64, OP>(src_column, src_offsets, cmp);
\
+ } else if (which.is_decimal32()) {
\
+ *dst = _apply_internal<Decimal32, OP>(src_column, src_offsets,
cmp); \
+ } else if (which.is_decimal64()) {
\
+ *dst = _apply_internal<Decimal64, OP>(src_column, src_offsets,
cmp); \
+ } else if (which.is_decimal128()) {
\
+ *dst = _apply_internal<Decimal128, OP>(src_column, src_offsets,
cmp); \
+ } else if (which.is_decimal128i()) {
\
+ *dst = _apply_internal<Decimal128I, OP>(src_column, src_offsets,
cmp); \
+ } else {
\
+ LOG(FATAL) << "unsupported type " << nested_type->get_name();
\
+ }
\
+ } while (0)
+
+ Status _execute(const IColumn& nested_src, DataTypePtr nested_type,
+ const ColumnArray::Offsets64& offsets, const std::string&
condition,
+ const ColumnConst& rhs_value_column, ColumnPtr* dst) {
+ if (condition == "=") {
+ APPLY_ALL_TYPES(nested_src, offsets, ApplyOp::EQ,
rhs_value_column, dst);
+ } else if (condition == "!=") {
+ APPLY_ALL_TYPES(nested_src, offsets, ApplyOp::NE,
rhs_value_column, dst);
+ } else if (condition == ">=") {
+ APPLY_ALL_TYPES(nested_src, offsets, ApplyOp::GE,
rhs_value_column, dst);
+ } else if (condition == "<=") {
+ APPLY_ALL_TYPES(nested_src, offsets, ApplyOp::LE,
rhs_value_column, dst);
+ } else if (condition == "<") {
+ APPLY_ALL_TYPES(nested_src, offsets, ApplyOp::LT,
rhs_value_column, dst);
+ } else if (condition == ">") {
+ APPLY_ALL_TYPES(nested_src, offsets, ApplyOp::GT,
rhs_value_column, dst);
+ } else {
+ return Status::RuntimeError(
+ fmt::format("execute failed, unsupported op {} for
function {})", condition,
+ "array_apply"));
+ }
+ return Status::OK();
+ }
+};
+
+void register_function_array_apply(SimpleFunctionFactory& factory) {
+ factory.register_function<FunctionArrayApply>();
+}
+
+} // namespace doris::vectorized
diff --git a/be/src/vec/functions/array/function_array_register.cpp
b/be/src/vec/functions/array/function_array_register.cpp
index 3d13a86862..aa64dff785 100644
--- a/be/src/vec/functions/array/function_array_register.cpp
+++ b/be/src/vec/functions/array/function_array_register.cpp
@@ -41,6 +41,7 @@ void register_function_array_compact(SimpleFunctionFactory&);
void register_function_array_popback(SimpleFunctionFactory&);
void register_function_array_with_constant(SimpleFunctionFactory&);
void register_function_array_constructor(SimpleFunctionFactory&);
+void register_function_array_apply(SimpleFunctionFactory&);
void register_function_array(SimpleFunctionFactory& factory) {
register_function_array_element(factory);
@@ -62,6 +63,7 @@ void register_function_array(SimpleFunctionFactory& factory) {
register_function_array_popback(factory);
register_function_array_with_constant(factory);
register_function_array_constructor(factory);
+ register_function_array_apply(factory);
}
} // namespace doris::vectorized
diff --git
a/docs/en/docs/sql-manual/sql-functions/array-functions/array_apply.md
b/docs/en/docs/sql-manual/sql-functions/array-functions/array_apply.md
new file mode 100644
index 0000000000..6b5450f73f
--- /dev/null
+++ b/docs/en/docs/sql-manual/sql-functions/array-functions/array_apply.md
@@ -0,0 +1,81 @@
+---
+{
+ "title": "array_apply",
+ "language": "en"
+}
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## array_apply
+
+<version since="1.2.3">
+
+array_apply
+
+</version>
+
+### description
+
+Filter array to match specific binary condition
+
+#### Syntax
+
+```sql
+array_apply(arr, op, val)
+```
+
+#### Arguments
+
+`arr` — The array to inspect. If it null, null will be returned.
+`op` — The compare operation, op includes `=`, `>=`, `<=`, `>`, `<`, `!=`
+`val` — The compared value.If it null, null will be returned.
+
+#### Returned value
+
+The filtered array matched with condition.
+
+Type: Array.
+
+### notice
+
+`Only supported in vectorized engine`
+
+### example
+
+```
+mysql> select array_apply([1, 2, 3, 4, 5], ">=", 2);
++--------------------------------------------+
+| array_apply(ARRAY(1, 2, 3, 4, 5), '>=', 2) |
++--------------------------------------------+
+| [2, 3, 4, 5] |
++--------------------------------------------+
+1 row in set (0.01 sec)
+
+mysql> select array_apply([1000000, 1000001, 1000002], "=", "1000002");
++-------------------------------------------------------------+
+| array_apply(ARRAY(1000000, 1000001, 1000002), '=', 1000002) |
++-------------------------------------------------------------+
+| [1000002] |
++-------------------------------------------------------------+
+1 row in set (0.01 sec)
+```
+
+### keywords
+
+ARRAY,APPLY,ARRAY_APPLY
\ No newline at end of file
diff --git
a/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_apply.md
b/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_apply.md
new file mode 100644
index 0000000000..fb94859e3a
--- /dev/null
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_apply.md
@@ -0,0 +1,80 @@
+---
+{
+ "title": "array_apply",
+ "language": "zh-CN"
+}
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## array_apply
+
+<version since="1.2.3">
+
+array_apply
+
+</version>
+
+### description
+数组以特定的二元条件符过滤元素, 并返回过滤后的结果
+
+#### Syntax
+
+```sql
+array_apply(arr, op, val)
+```
+
+#### Arguments
+
+`arr` — 输入的数组, 如果是null, 则返回null
+`op` — 过滤条件, 条件包括 `=`, `>=`, `<=`, `>`, `<`, `!=`
+`val` — 过滤的条件值, 如果是null, 则返回null
+
+#### Returned value
+
+过滤后的数组
+
+类型: Array.
+
+### notice
+
+`只支持在向量化引擎中使用。`
+
+### example
+
+```
+mysql> select array_apply([1, 2, 3, 4, 5], ">=", 2);
++--------------------------------------------+
+| array_apply(ARRAY(1, 2, 3, 4, 5), '>=', 2) |
++--------------------------------------------+
+| [2, 3, 4, 5] |
++--------------------------------------------+
+1 row in set (0.01 sec)
+
+mysql> select array_apply([1000000, 1000001, 1000002], "=", "1000002");
++-------------------------------------------------------------+
+| array_apply(ARRAY(1000000, 1000001, 1000002), '=', 1000002) |
++-------------------------------------------------------------+
+| [1000002] |
++-------------------------------------------------------------+
+1 row in set (0.01 sec)
+```
+
+### keywords
+
+ARRAY,APPLY,ARRAY_APPLY
\ No newline at end of file
diff --git a/gensrc/script/doris_builtins_functions.py
b/gensrc/script/doris_builtins_functions.py
index ea65c670b2..d5060303dc 100644
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -394,6 +394,23 @@ visible_functions = [
[['array_union'], 'ARRAY_VARCHAR', ['ARRAY_VARCHAR', 'ARRAY_VARCHAR'],
''],
[['array_union'], 'ARRAY_STRING', ['ARRAY_STRING', 'ARRAY_STRING'], ''],
+ [['array_apply'], 'ARRAY_BOOLEAN', ['ARRAY_BOOLEAN', 'VARCHAR',
'BOOLEAN'], ''],
+ [['array_apply'], 'ARRAY_TINYINT', ['ARRAY_TINYINT', 'VARCHAR',
'TINYINT'], ''],
+ [['array_apply'], 'ARRAY_SMALLINT', ['ARRAY_SMALLINT', 'VARCHAR',
'SMALLINT'], ''],
+ [['array_apply'], 'ARRAY_INT', ['ARRAY_INT', 'VARCHAR', 'INT'], ''],
+ [['array_apply'], 'ARRAY_BIGINT', ['ARRAY_BIGINT', 'VARCHAR', 'BIGINT'],
''],
+ [['array_apply'], 'ARRAY_LARGEINT', ['ARRAY_LARGEINT', 'VARCHAR',
'ARRAY_LARGEINT'], ''],
+ [['array_apply'], 'ARRAY_FLOAT', ['ARRAY_FLOAT', 'VARCHAR', 'FLOAT'],
''],
+ [['array_apply'], 'ARRAY_DOUBLE', ['ARRAY_DOUBLE', 'VARCHAR',
'DOUBLE'], ''],
+ [['array_apply'], 'ARRAY_DECIMALV2', ['ARRAY_DECIMALV2', 'VARCHAR',
'DECIMALV2'], ''],
+ [['array_apply'], 'ARRAY_DECIMAL32', ['ARRAY_DECIMAL32', 'VARCHAR',
'DECIMAL32'], ''],
+ [['array_apply'], 'ARRAY_DECIMAL64', ['ARRAY_DECIMAL64', 'VARCHAR',
'DECIMAL64'], ''],
+ [['array_apply'], 'ARRAY_DECIMAL128', ['ARRAY_DECIMAL128', 'VARCHAR',
'DECIMAL128'], ''],
+ [['array_apply'], 'ARRAY_DATETIME', ['ARRAY_DATETIME', 'VARCHAR',
'DATETIME'], ''],
+ [['array_apply'], 'ARRAY_DATE', ['ARRAY_DATE', 'DATE', 'DATE'], ''],
+ [['array_apply'], 'ARRAY_DATETIMEV2', ['ARRAY_DATETIMEV2', 'VARCHAR',
'DATETIMEV2'], ''],
+ [['array_apply'], 'ARRAY_DATEV2', ['ARRAY_DATEV2', 'VARCHAR',
'DATEV2'], ''],
+
[['array_except'], 'ARRAY_BOOLEAN', ['ARRAY_BOOLEAN', 'ARRAY_BOOLEAN'],
''],
[['array_except'], 'ARRAY_TINYINT', ['ARRAY_TINYINT', 'ARRAY_TINYINT'],
''],
[['array_except'], 'ARRAY_SMALLINT', ['ARRAY_SMALLINT', 'ARRAY_SMALLINT'],
''],
diff --git
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
index 2384f7bec7..a42e84b3b2 100644
---
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
+++
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
@@ -521,6 +521,21 @@ _
-- !sql --
[2023-02-06, 2023-02-05, 2023-02-07, 2023-02-05]
+-- !sql --
+[1000002]
+
+-- !sql --
+[2.222, 3.333]
+
+-- !sql --
+[2022-01-03 00:00:00, 2021-01-01 00:00:00]
+
+-- !sql --
+[25.99]
+
+-- !sql --
+[24.99]
+
-- !sql --
[8, NULL]
diff --git
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out
index 2376a7bb1f..c4463229de 100644
---
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out
+++
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_with_scale_type.out
@@ -78,3 +78,27 @@
-- !select --
[2022-12-02 22:23:24.999, 2022-12-02 22:23:23.997]
+-- !select --
+[]
+[]
+
+-- !select --
+[2022-12-01 22:23:24, 2022-12-01 23:23:24]
+[2022-12-02 22:23:24, 2022-12-02 23:23:24]
+
+-- !select --
+\N
+\N
+
+-- !select --
+[22.678]
+[]
+
+-- !select --
+[22.678, 33.6789]
+[23.678, 34.6789]
+
+-- !select --
+\N
+\N
+
diff --git
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
index c7afc7adb4..4f281116ad 100644
---
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
+++
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
@@ -216,6 +216,13 @@ suite("test_array_functions_by_literal") {
qt_sql "select array_compact(array(cast ('2023-02-06 22:07:34.999' as
datetimev2(3)),cast ('2023-02-04 23:07:34.999' as datetimev2(3)), cast
('2023-02-07 22:07:34.999' as datetimev2(3)),cast ('2023-02-04 23:07:34.999' as
datetimev2(3))))"
qt_sql "select array_compact(array(cast ('2023-02-06' as datev2), cast
('2023-02-05' as datev2), cast ('2023-02-07' as datev2), cast ('2023-02-05' as
datev2)))"
+ // array_apply
+ qt_sql """select array_apply([1000000, 1000001, 1000002], '=', 1000002)"""
+ qt_sql """select array_apply([1.111, 2.222, 3.333], '>=', 2)"""
+ qt_sql """select array_apply(cast(array("2020-01-02", "2022-01-03",
"2021-01-01", "1996-04-17") as array<datetimev2>), ">", '2020-01-02')"""
+ qt_sql """select array_apply(array(cast (24.99 as decimal(10,3)),cast
(25.99 as decimal(10,3))), ">", '25')"""
+ qt_sql """select array_apply(array(cast (24.99 as decimal(10,3)),cast
(25.99 as decimal(10,3))), "!=", '25.99')"""
+
qt_sql "select array(8, null)"
qt_sql "select array('a', 1, 2)"
qt_sql "select array(null, null, null)"
diff --git
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_with_scale_type.groovy
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_with_scale_type.groovy
index 827f03858c..ae206f07d2 100644
---
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_with_scale_type.groovy
+++
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_with_scale_type.groovy
@@ -68,5 +68,12 @@ suite("test_array_with_scale_type") {
qt_select "select array(cast ('2022-12-02 22:23:24.999999' as
datetimev2(3)),cast ('2022-12-02 22:23:23.997799' as datetimev2(3))) from
${tableName}"
qt_select "select array(cast ('2022-12-02 22:23:24.999999' as
datetimev2(3)),cast ('2022-12-02 22:23:23.997799' as datetimev2(3)))"
+ qt_select """select array_apply(c_array_datetimev2, "=", '2022-12-02
22:23:24.999999') from ${tableName}"""
+ qt_select """select array_apply(c_array_datetimev2, ">", '2022-12-01
22:23:24.999999') from ${tableName}"""
+ qt_select """select array_apply(c_array_datetimev2, ">", null) from
${tableName}"""
+ qt_select """select array_apply(c_array_decimal, "=", 22.678) from
${tableName}"""
+ qt_select """select array_apply(c_array_decimal, ">=", 22.1) from
${tableName}"""
+ qt_select """select array_apply(c_array_decimal, ">=", null) from
${tableName}"""
+
sql "DROP TABLE IF EXISTS ${tableName}"
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]