This is an automated email from the ASF dual-hosted git repository.
eldenmoon 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 adb21f956e6 [fix](array_apply) array_apply replace logFatal with throw
exception (#39105)
adb21f956e6 is described below
commit adb21f956e6212a631b34ec9e0bda4e4126835cc
Author: amory <[email protected]>
AuthorDate: Wed Aug 14 09:56:26 2024 +0800
[fix](array_apply) array_apply replace logFatal with throw exception
(#39105)
if we use sql with string:
we will meet coredump below:
```
[WARNING!] /sys/kernel/mm/transparent_hugepage/enabled: [always] madvise
never, Doris not recommend turning on THP, which may cause the BE process to
use more memory and cannot be freed in time. Turn off THP: `echo madvise | sudo
tee /sys/kernel/mm/transparent_hugepage/enabled`
start BE in local mode
F20240807 22:30:39.816305 1767121 function_array_apply.cpp:227] unsupported
type Nullable(String)
*** Check failure stack trace: ***
@ 0x55e6a10363b6 google::LogMessage::SendToLog()
@ 0x55e6a1032e00 google::LogMessage::Flush()
@ 0x55e6a1036bf9 google::LogMessageFatal::~LogMessageFatal()
@ 0x55e67b721ef9 doris::vectorized::FunctionArrayApply::_execute()
@ 0x55e67b71af19
doris::vectorized::FunctionArrayApply::execute_impl()
@ 0x55e67a9adba7
doris::vectorized::DefaultExecutable::execute_impl()
@ 0x55e68107e47d
doris::vectorized::PreparedFunctionImpl::_execute_skipped_constant_deal()
@ 0x55e681065f90
doris::vectorized::PreparedFunctionImpl::default_implementation_for_constant_arguments()
@ 0x55e681068ae0
doris::vectorized::PreparedFunctionImpl::execute_without_low_cardinality_columns()
@ 0x55e681069032 doris::vectorized::PreparedFunctionImpl::execute()
@ 0x55e67a9a85da doris::vectorized::IFunctionBase::execute()
@ 0x55e67a98c880 doris::vectorized::VectorizedFnCall::_do_execute()
@ 0x55e67a98ce58 doris::vectorized::VectorizedFnCall::execute()
@ 0x55e67a9ccdcb doris::vectorized::VExpr::get_const_col()
@ 0x55e67a988cdc doris::vectorized::VectorizedFnCall::open()
@ 0x55e67aabda3f doris::vectorized::VExprContext::open()
@ 0x55e65499e757 doris::FoldConstantExecutor::_prepare_and_open<>()
@ 0x55e654986927 doris::FoldConstantExecutor::fold_constant_vexpr()
@ 0x55e65486de05 doris::PInternalService::_fold_constant_expr()
@ 0x55e6548bd36a
doris::PInternalService::fold_constant_expr()::$_0::operator()()
@ 0x55e6548bc84f std::__invoke_impl<>()
@ 0x55e6548bc78f
_ZSt10__invoke_rIvRZN5doris16PInternalService18fold_constant_exprEPN6google8protobuf13RpcControllerEPKNS0_20PConstantExprRequestEPNS0_19PConstantExprResultEPNS3_7ClosureEE3$_0JEENSt9enable_ifIX16is_invocable_r_vIT_T0_DpT1_EESG_E4typeEOSH_DpOSI_
@ 0x55e6548bc466 std::_Function_handler<>::_M_invoke()
@ 0x55e64e07b8eb std::function<>::operator()()
@ 0x55e6549172f5 doris::WorkThreadPool<>::work_thread()
@ 0x55e654919de9 std::__invoke_impl<>()
@ 0x55e654919bb3 std::__invoke<>()
@ 0x55e654919b19
_ZNKSt12_Mem_fn_baseIMN5doris14WorkThreadPoolILb0EEEFviELb1EEclIJRPS2_RiEEEDTclsr3stdE8__invokedtdefpT6_M_pmfspclsr3stdE7forwardIT_Efp_EEEDpOSA_
@ 0x55e654919a63 std::__invoke_impl<>()
@ 0x55e654919873
_ZSt10__invoke_rIvRSt7_Mem_fnIMN5doris14WorkThreadPoolILb0EEEFviEEJRPS3_RiEENSt9enable_ifIX16is_invocable_r_vIT_T0_DpT1_EESC_E4typeEOSD_DpOSE_
@ 0x55e654919785
_ZNSt12_Bind_resultIvFSt7_Mem_fnIMN5doris14WorkThreadPoolILb0EEEFviEEPS3_iEE6__callIvJEJLm0ELm1EEEET_OSt5tupleIJDpT0_EESt12_Index_tupleIJXspT1_EEE
@ 0x55e6549194b6 std::_Bind_result<>::operator()<>()
*** Query id: 0-0 ***
*** is nereids: 0 ***
*** tablet id: 0 ***
*** Aborted at 1723041040 (unix time) try "date -d @1723041040" if you are
using GNU date ***
*** Current BE git commitID: f4422905f8 ***
*** SIGABRT unknown detail explain (@0x461001aef86) received by PID 1765254
(TID 1767121 OR 0x7fd88b686700) from PID 1765254; stack trace: ***
0# doris::signal::(anonymous namespace)::FailureSignalHandler(int,
siginfo_t*, void*) at
/mnt/disk1/wangqiannan/amory/doris/be/src/common/signal_handler.h:421
1# 0x00007FDECA380B50 in /lib64/libc.so.6
2# gsignal in /lib64/libc.so.6
3# __GI_abort in /lib64/libc.so.6
4# 0x000055E6A1040C2D in
/mnt/disk1/wangqiannan/amory/doris/output/be/lib/doris_be
5# 0x000055E6A10332CA in
/mnt/disk1/wangqiannan/amory/doris/output/be/lib/doris_be
6# google::LogMessage::SendToLog() in
/mnt/disk1/wangqiannan/amory/doris/output/be/lib/doris_be
```
---
.../vec/functions/array/function_array_apply.cpp | 87 +++++++++++-----------
.../expressions/functions/scalar/ArrayApply.java | 10 +++
.../nereids_function_p0/scalar_function/Array.out | 3 +
.../test_array_functions_by_literal.out | 3 +
.../scalar_function/Array.groovy | 10 +++
.../test_array_functions_by_literal.groovy | 9 +++
6 files changed, 80 insertions(+), 42 deletions(-)
diff --git a/be/src/vec/functions/array/function_array_apply.cpp
b/be/src/vec/functions/array/function_array_apply.cpp
index 2ad680635a7..426347c449b 100644
--- a/be/src/vec/functions/array/function_array_apply.cpp
+++ b/be/src/vec/functions/array/function_array_apply.cpp
@@ -173,48 +173,51 @@ private:
}
// need exception safety
-#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_decimal128v2()) {
\
- *dst = _apply_internal<Decimal128V2, OP>(src_column, src_offsets,
cmp); \
- } else if (which.is_decimal128v3()) {
\
- *dst = _apply_internal<Decimal128V3, OP>(src_column, src_offsets,
cmp); \
- } else if (which.is_decimal256()) {
\
- *dst = _apply_internal<Decimal256, OP>(src_column, src_offsets,
cmp); \
- } else {
\
- LOG(FATAL) << "unsupported type " << nested_type->get_name();
\
- }
\
+#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_decimal128v2()) {
\
+ *dst = _apply_internal<Decimal128V2, OP>(src_column, src_offsets,
cmp); \
+ } else if (which.is_decimal128v3()) {
\
+ *dst = _apply_internal<Decimal128V3, OP>(src_column, src_offsets,
cmp); \
+ } else if (which.is_decimal256()) {
\
+ *dst = _apply_internal<Decimal256, OP>(src_column, src_offsets,
cmp); \
+ } else {
\
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
\
+ "array_apply only accept array with nested
type which is " \
+ "uint/int/decimal/float/date but got : " +
\
+ nested_type->get_name());
\
+ }
\
} while (0)
// need exception safety
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ArrayApply.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ArrayApply.java
index 82bad4e4868..07e4c16d776 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ArrayApply.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ArrayApply.java
@@ -26,6 +26,7 @@ import
org.apache.doris.nereids.trees.expressions.literal.StringLikeLiteral;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.ArrayType;
+import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.VarcharType;
import org.apache.doris.nereids.types.coercion.AnyDataType;
import org.apache.doris.nereids.types.coercion.FollowToAnyDataType;
@@ -67,6 +68,15 @@ public class ArrayApply extends ScalarFunction
}
}
+ @Override
+ public void checkLegalityBeforeTypeCoercion() {
+ DataType argType = ((ArrayType) child(0).getDataType()).getItemType();
+ if (!(argType.isIntegralType() || argType.isFloatLikeType() ||
argType.isDecimalLikeType()
+ || argType.isDateLikeType() || argType.isBooleanType())) {
+ throw new AnalysisException("array_apply does not support type: "
+ toSql());
+ }
+ }
+
@Override
public ArrayApply withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 3,
diff --git a/regression-test/data/nereids_function_p0/scalar_function/Array.out
b/regression-test/data/nereids_function_p0/scalar_function/Array.out
index bc99cd9c386..17e8db9a68d 100644
--- a/regression-test/data/nereids_function_p0/scalar_function/Array.out
+++ b/regression-test/data/nereids_function_p0/scalar_function/Array.out
@@ -14451,3 +14451,6 @@ true
-- !array_empty_be --
[]
+-- !sql_array_map --
+[1, 1, 1, 1]
+
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 6f3b1756d48..bddcebea700 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
@@ -977,3 +977,6 @@ _
-- !sql --
[11.9999, 34.0000]
+-- !sql_array_map --
+[1, 1, 1, 1]
+
diff --git
a/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy
b/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy
index ef3813d6deb..4ad14814490 100644
--- a/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy
+++ b/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy
@@ -1310,4 +1310,14 @@ suite("nereids_scalar_fn_Array") {
qt_array_empty_fe """select array()"""
sql """ set debug_skip_fold_constant=true; """
qt_array_empty_be """select array()"""
+
+ // array_map with string is can be succeed
+ qt_sql_array_map """select array_map(x->x!='',
split_by_string('amory,is,better,committing', ','))"""
+
+ // array_apply with string should be failed
+ test {
+ sql """select array_apply(split_by_string("amory,is,better,committing",
","), '!=', '');"""
+ exception("errCode = 2")
+ }
+
}
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 f335cd72115..81689b63359 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
@@ -410,4 +410,13 @@ suite("test_array_functions_by_literal") {
} catch (Exception ex) {
assert("${ex}".contains("errCode = 2, detailMessage = No matching
function with signature: array_intersect"))
}
+
+ // array_map with string is can be succeed
+ qt_sql_array_map """ select array_map(x->x!='',
split_by_string('amory,is,better,committing', ',')) """
+
+ // array_apply with string should be failed
+ test {
+ sql """select array_apply(split_by_string("amory,is,better,committing",
","), '!=', '');"""
+ exception("No matching function")
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]