You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2025/04/24 07:28:19 UTC
(doris) branch branch-2.1 updated: branch-2.1: [fix](array_map) fix array_map functions avoid core #50201 (#50331)
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 91eed373beb branch-2.1: [fix](array_map) fix array_map functions avoid core #50201 (#50331)
91eed373beb is described below
commit 91eed373beb76aada17068d6d8649b4ab9995a40
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Thu Apr 24 15:28:12 2025 +0800
branch-2.1: [fix](array_map) fix array_map functions avoid core #50201 (#50331)
Cherry-picked from #50201
---------
Co-authored-by: amory <wa...@selectdb.com>
---
.../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 93b9dc4d5c4..5b908493a7c 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
@@ -103,6 +103,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..f61c3f1a454
--- /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 "The lambda function of params must be array type"
+ }
+ // 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 "The lambda function of params must be array type"
+ }
+
+
+ test {
+ sql """
+ select array_map(x -> x is null, arr[0]) from test_table;
+ """
+ exception "The lambda function of params must be array type"
+ }
+
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org