This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 56554ddc6ef [fix](array-func)fix func array_enumerate_uniq with param
is nullable return #38384 (#38720)
56554ddc6ef is described below
commit 56554ddc6ef0615ada38d322fc7290db11a148b7
Author: amory <[email protected]>
AuthorDate: Fri Aug 2 19:53:48 2024 +0800
[fix](array-func)fix func array_enumerate_uniq with param is nullable
return #38384 (#38720)
---
be/src/vec/functions/array/function_array_enumerate.cpp | 1 -
.../functions/array/function_array_enumerate_uniq.cpp | 9 +++------
.../array_functions/test_array_functions.groovy | 17 +++++++++++++++++
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/be/src/vec/functions/array/function_array_enumerate.cpp
b/be/src/vec/functions/array/function_array_enumerate.cpp
index 9594f87ba89..911e4f15eae 100644
--- a/be/src/vec/functions/array/function_array_enumerate.cpp
+++ b/be/src/vec/functions/array/function_array_enumerate.cpp
@@ -56,7 +56,6 @@ public:
static constexpr auto name = "array_enumerate";
static FunctionPtr create() { return
std::make_shared<FunctionArrayEnumerate>(); }
String get_name() const override { return name; }
- bool use_default_implementation_for_nulls() const override { return false;
}
size_t get_number_of_arguments() const override { return 1; }
DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
const DataTypeArray* array_type =
diff --git a/be/src/vec/functions/array/function_array_enumerate_uniq.cpp
b/be/src/vec/functions/array/function_array_enumerate_uniq.cpp
index e3b8aa4bf6a..b1adde8d205 100644
--- a/be/src/vec/functions/array/function_array_enumerate_uniq.cpp
+++ b/be/src/vec/functions/array/function_array_enumerate_uniq.cpp
@@ -75,7 +75,6 @@ public:
String get_name() const override { return name; }
bool is_variadic() const override { return true; }
size_t get_number_of_arguments() const override { return 1; }
- bool use_default_implementation_for_nulls() const override { return false;
}
DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
if (arguments.empty()) {
@@ -91,15 +90,13 @@ public:
" must be an array but it has type " +
arguments[i]->get_name() + ".";
}
- if (i == 0) {
- is_nested_nullable =
array_type->get_nested_type()->is_nullable();
- }
+ is_nested_nullable = is_nested_nullable ||
array_type->get_nested_type()->is_nullable();
}
auto return_nested_type = std::make_shared<DataTypeInt64>();
DataTypePtr return_type = std::make_shared<DataTypeArray>(
is_nested_nullable ? make_nullable(return_nested_type) :
return_nested_type);
- if (arguments.size() == 1 && arguments[0]->is_nullable()) {
+ if (arguments[0]->is_nullable()) {
return_type = make_nullable(return_type);
}
return return_type;
@@ -143,7 +140,7 @@ public:
src_offsets = array->get_offsets_ptr();
} else if (*offsets != cur_offsets) {
return Status::RuntimeError(fmt::format(
- "lengths of all arrays of fucntion {} must be equal.",
get_name()));
+ "lengths of all arrays of function {} must be equal.",
get_name()));
}
const auto* array_data = &array->get_data();
data_columns[i] = array_data;
diff --git
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
index 56ab9a7c3c1..ca78c2c1a49 100644
---
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
+++
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
@@ -337,6 +337,23 @@ suite("test_array_functions") {
(12, 1.200, 1.200000000 , 1.200, 1.20000, 1.200000000,
[1.200000000, 1.200000000]); """
qt_sql """ select array_position(kadcml, kdcmls1), kadcml, kdcmls1 from
fn_test;"""
+ sql """ DROP TABLE IF EXISTS ARRAY_BIGINT_DATA;"""
+ sql """ CREATE TABLE IF NOT EXISTS `ARRAY_BIGINT_DATA` (
+ `id` INT NULL,
+ `data` ARRAY<BIGINT> NULL
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`id`)
+ DISTRIBUTED BY HASH(`id`) BUCKETS 10
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ );"""
+ sql """ INSERT INTO ARRAY_BIGINT_DATA VALUES (0, [-1, 0, 1, 2,
-9223372036854775808, 9223372036854775807, 1]);"""
+ sql """ INSERT INTO ARRAY_BIGINT_DATA VALUES (1, []);"""
+
+ test {
+ sql """ select array_enumerate_uniq((select data from ARRAY_BIGINT_DATA
where id = 0), (select data from ARRAY_BIGINT_DATA where id = 1), (select data
from ARRAY_BIGINT_DATA where id = 1));"""
+ exception ("A subquery should not return Array/Map/Struct type")
+ }
// test large size of array
test {
sql """ select sequence(1, 10000000000); """
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]