This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new cccff540a62 branch-3.0: [fix](array_map) fix array_map functions avoid
core #50201 (#50330)
cccff540a62 is described below
commit cccff540a62b52e6922a4e7eb1f13d805d5c62cf
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue May 6 10:05:19 2025 +0800
branch-3.0: [fix](array_map) fix array_map functions avoid core #50201
(#50330)
Cherry-picked from #50201
Co-authored-by: amory <[email protected]>
---
.../doris/analysis/LambdaFunctionCallExpr.java | 3 +
.../data/datatype_p0/complex_types/test.json | 3 +
.../complex_types/test_load_with_functions.groovy | 81 ++++++++++++++++++++++
3 files changed, 87 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/LambdaFunctionCallExpr.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/LambdaFunctionCallExpr.java
index 707f76f9672..500f0585dc8 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/LambdaFunctionCallExpr.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/analysis/LambdaFunctionCallExpr.java
@@ -107,6 +107,9 @@ public class LambdaFunctionCallExpr extends
FunctionCallExpr {
Expr lastChild = getChild(childSize - 1);
for (int i = childSize - 1; i > 0; --i) {
argTypes[i] = getChild(i - 1).getType();
+ if (!argTypes[i].isArrayType()) {
+ throw new AnalysisException("array_map function only
support array type as input params");
+ }
this.setChild(i, getChild(i - 1));
}
argTypes[0] = lastType;
diff --git a/regression-test/data/datatype_p0/complex_types/test.json
b/regression-test/data/datatype_p0/complex_types/test.json
new file mode 100644
index 00000000000..598a193f1a0
--- /dev/null
+++ b/regression-test/data/datatype_p0/complex_types/test.json
@@ -0,0 +1,3 @@
+[{"arr": ["a\nb", "a\nb","a\tb","a"b","a\rb","a\bb"]},
+{"arr": ["\\A"]},
+{"arr": ["a"b", "c","d"]}]
diff --git
a/regression-test/suites/datatype_p0/complex_types/test_load_with_functions.groovy
b/regression-test/suites/datatype_p0/complex_types/test_load_with_functions.groovy
new file mode 100644
index 00000000000..7194e9ded52
--- /dev/null
+++
b/regression-test/suites/datatype_p0/complex_types/test_load_with_functions.groovy
@@ -0,0 +1,81 @@
+// 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.
+
+suite("test_load_with_functions") {
+ sql "DROP TABLE IF EXISTS `test_table`"
+ sql """
+ create table IF NOT EXISTS `test_table` (
+ `id` int NULL,
+ `arr` array<text> NULL
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`id`) distributed by hash(`id`) buckets 1
properties("replication_num" = "1");
+ """
+
+ // curl -v --location-trusted -u root: -H "format:json" -H
"strip_outer_array:true" -H "read_json_by_line: true" -H "group_mode:
sync_mode" -H "columns:arr=ARRAY_MAP(x -> IFNULL(x, '$'), arr)" -T test.json
+ streamLoad {
+ table "test_table"
+ set 'strip_outer_array', 'true'
+ set 'read_json_by_line', 'true'
+ set 'group_mode', 'sync_mode'
+ set 'columns', 'arr=ARRAY_MAP(x -> IFNULL(x, \'$\'), arr)'
+ set 'format', 'json'
+ file "test.json"
+ time 60
+
+ // if declared a check callback, the default check condition will
ignore.
+ // So you must check all condition
+ check { result, exception, startTime, endTime ->
+ if (exception != null) {
+ throw exception
+ }
+ log.info("Stream load result: ${result}".toString())
+ def json = parseJson(result)
+ assertEquals("fail", json.Status.toLowerCase())
+ }
+ }
+
+ // test array_map with non-array arg for nereids which should throw
exception
+ // literal
+
+ test {
+ sql """
+ select array_map(x -> x is null, "sss");
+ """
+ exception "lambda argument must be array"
+ }
+ // column
+ sql """ insert into test_table values(1, ["a", "b", "c"]) """
+ sql """ insert into test_table values(2, ["a", "b", "c"]) """
+
+
+ test {
+ sql """
+ select array_map(x -> x is null, id) from test_table;
+ """
+ exception "lambda argument must be array"
+ }
+
+
+ test {
+ sql """
+ select array_map(x -> x is null, arr[0]) from test_table;
+ """
+ exception "lambda argument must be array"
+ }
+
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]