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 2022/07/26 11:30:15 UTC
[doris] branch master updated: [bugfix]fix constant argument coredump (#11200)
This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 2e210fb363 [bugfix]fix constant argument coredump (#11200)
2e210fb363 is described below
commit 2e210fb36350b1c48598b4755807c545e78626b6
Author: xy720 <22...@users.noreply.github.com>
AuthorDate: Tue Jul 26 19:30:06 2022 +0800
[bugfix]fix constant argument coredump (#11200)
---
.../apache/doris/analysis/FunctionCallExpr.java | 12 ++++
.../java/org/apache/doris/catalog/ArrayType.java | 4 ++
.../test_array_functions_by_literal.out | 81 ++++++++++++++++++++++
.../test_array_functions_by_literal.groovy | 37 ++++++++++
4 files changed, 134 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index d05c7adfc0..8407726208 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -1102,6 +1102,18 @@ public class FunctionCallExpr extends Expr {
this.type = new ArrayType(children.get(0).getType());
}
}
+
+ if (this.type instanceof ArrayType) {
+ ArrayType arrayType = (ArrayType) type;
+ boolean containsNull = false;
+ for (Expr child : children) {
+ Type childType = child.getType();
+ if (childType instanceof ArrayType) {
+ containsNull |= ((ArrayType) childType).getContainsNull();
+ }
+ }
+ arrayType.setContainsNull(containsNull);
+ }
}
/**
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/ArrayType.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/ArrayType.java
index 26f4aa0aec..a2a9092b10 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ArrayType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ArrayType.java
@@ -62,6 +62,10 @@ public class ArrayType extends Type {
return containsNull;
}
+ public void setContainsNull(boolean containsNull) {
+ this.containsNull = containsNull;
+ }
+
@Override
public PrimitiveType getPrimitiveType() {
return PrimitiveType.ARRAY;
diff --git a/regression-test/data/query/sql_functions/array_functions/test_array_functions_by_literal.out b/regression-test/data/query/sql_functions/array_functions/test_array_functions_by_literal.out
index 0a37764fb7..406ff361fa 100644
--- a/regression-test/data/query/sql_functions/array_functions/test_array_functions_by_literal.out
+++ b/regression-test/data/query/sql_functions/array_functions/test_array_functions_by_literal.out
@@ -109,3 +109,84 @@ false
-- !sql --
3
+
+-- !sql --
+2
+
+-- !sql --
+6
+
+-- !sql --
+1
+
+-- !sql --
+3
+
+-- !sql --
+[1, 2, 3]
+
+-- !sql --
+[1, 2, 3, NULL]
+
+-- !sql --
+['a']
+
+-- !sql --
+['a', NULL]
+
+-- !sql --
+[2, 3]
+
+-- !sql --
+[2, 3, NULL]
+
+-- !sql --
+['b', 'c']
+
+-- !sql --
+['b', 'c', NULL]
+
+-- !sql --
+[1, 2, 3]
+
+-- !sql --
+[1, 2, 3]
+
+-- !sql --
+[NULL, 1, 2, 3]
+
+-- !sql --
+[NULL, 1, 2, 3]
+
+-- !sql --
+['a', 'b', 'c']
+
+-- !sql --
+['a', 'b', 'c']
+
+-- !sql --
+false
+
+-- !sql --
+true
+
+-- !sql --
+\N
+
+-- !sql --
+[1, 2, 3, 4]
+
+-- !sql --
+[1]
+
+-- !sql --
+[2, 3]
+
+-- !sql --
+[1, 2, 3, 4, NULL]
+
+-- !sql --
+[1]
+
+-- !sql --
+[2, 3]
diff --git a/regression-test/suites/query/sql_functions/array_functions/test_array_functions_by_literal.groovy b/regression-test/suites/query/sql_functions/array_functions/test_array_functions_by_literal.groovy
index 2fbc570e82..a7b73fd5e7 100644
--- a/regression-test/suites/query/sql_functions/array_functions/test_array_functions_by_literal.groovy
+++ b/regression-test/suites/query/sql_functions/array_functions/test_array_functions_by_literal.groovy
@@ -65,4 +65,41 @@ suite("test_array_functions_by_literal", "all") {
qt_sql "select array_sum([1,2,3])"
qt_sql "select array_min([1,2,3])"
qt_sql "select array_max([1,2,3])"
+ qt_sql "select array_avg([1,2,3,null])"
+ qt_sql "select array_sum([1,2,3,null])"
+ qt_sql "select array_min([1,2,3,null])"
+ qt_sql "select array_max([1,2,3,null])"
+
+ // array_distinct function
+ qt_sql "select array_distinct([1,1,2,2,3,3])"
+ qt_sql "select array_distinct([1,1,2,2,3,3,null])"
+ qt_sql "select array_distinct(['a','a','a'])"
+ qt_sql "select array_distinct(['a','a','a',null])"
+
+ // array_remove function
+ qt_sql "select array_remove([1,2,3], 1)"
+ qt_sql "select array_remove([1,2,3,null], 1)"
+ qt_sql "select array_remove(['a','b','c'], 'a')"
+ qt_sql "select array_remove(['a','b','c',null], 'a')"
+
+ // array_sort function
+ qt_sql "select array_sort([1,2,3])"
+ qt_sql "select array_sort([3,2,1])"
+ qt_sql "select array_sort([1,2,3,null])"
+ qt_sql "select array_sort([null,1,2,3])"
+ qt_sql "select array_sort(['a','b','c'])"
+ qt_sql "select array_sort(['c','b','a'])"
+
+ // array_overlap function
+ qt_sql "select arrays_overlap([1,2,3], [4,5,6])"
+ qt_sql "select arrays_overlap([1,2,3], [3,4,5])"
+ qt_sql "select arrays_overlap([1,2,3,null], [3,4,5])"
+
+ // array_binary function
+ qt_sql "select array_union([1,2,3], [2,3,4])"
+ qt_sql "select array_except([1,2,3], [2,3,4])"
+ qt_sql "select array_intersect([1,2,3], [2,3,4])"
+ qt_sql "select array_union([1,2,3], [2,3,4,null])"
+ qt_sql "select array_except([1,2,3], [2,3,4,null])"
+ qt_sql "select array_intersect([1,2,3], [2,3,4,null])"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org