This is an automated email from the ASF dual-hosted git repository.

lihaopeng 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 e04b9cb47e [vectorized](function) fix array_map funtion return type 
maybe get wrong (#19320)
e04b9cb47e is described below

commit e04b9cb47edf2ee1a69e1828013a07440d53e2c8
Author: zhangstar333 <[email protected]>
AuthorDate: Thu May 25 11:30:28 2023 +0800

    [vectorized](function) fix array_map funtion return type maybe get wrong 
(#19320)
---
 .../org/apache/doris/analysis/ColumnRefExpr.java   |  2 +-
 .../doris/analysis/LambdaFunctionCallExpr.java     | 34 +++++-----------------
 gensrc/script/doris_builtins_functions.py          |  1 -
 3 files changed, 9 insertions(+), 28 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnRefExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnRefExpr.java
index 2e7308aeb5..ef0e37e2fa 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnRefExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnRefExpr.java
@@ -83,7 +83,7 @@ public class ColumnRefExpr extends Expr {
 
     @Override
     protected String toSqlImpl() {
-        return columnName + "(" + columnId + ")";
+        return columnName;
     }
 
     @Override
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 7614d17f1a..030db56092 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
@@ -19,6 +19,7 @@ package org.apache.doris.analysis;
 
 import org.apache.doris.catalog.ArrayType;
 import org.apache.doris.catalog.Function;
+import org.apache.doris.catalog.Function.NullableMode;
 import org.apache.doris.catalog.Type;
 import org.apache.doris.common.AnalysisException;
 import org.apache.doris.thrift.TExprNode;
@@ -30,6 +31,7 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 public class LambdaFunctionCallExpr extends FunctionCallExpr {
@@ -99,14 +101,13 @@ public class LambdaFunctionCallExpr extends 
FunctionCallExpr {
                 this.setChild(0, lastChild);
             }
 
-            fn = getBuiltinFunction(fnName.getFunction(), argTypes,
-                    Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
             Expr lambda = this.children.get(0);
-            if (fn == null) {
-                LOG.warn("fn {} not exists", this.toSqlImpl());
-                throw new 
AnalysisException(getFunctionNotFoundError(collectChildReturnTypes()));
+            if (!(lambda instanceof LambdaFunctionExpr)) {
+                throw new AnalysisException("array_map must use lambda as 
first input params, now is"
+                        + lambda.debugString());
             }
-            fn.setReturnType(ArrayType.create(lambda.getChild(0).getType(), 
true));
+            fn = new Function(fnName, Arrays.asList(argTypes), 
ArrayType.create(lambda.getChild(0).getType(), true),
+                    true, true, NullableMode.DEPEND_ON_ARGUMENT);
         } else if (fnName.getFunction().equalsIgnoreCase("array_exists")
                 || fnName.getFunction().equalsIgnoreCase("array_first_index")
                 || fnName.getFunction().equalsIgnoreCase("array_count")) {
@@ -138,10 +139,6 @@ public class LambdaFunctionCallExpr extends 
FunctionCallExpr {
 
             fn = getBuiltinFunction(fnName.getFunction(), newArgTypes,
                     Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
-            if (fn == null) {
-                LOG.warn("fn {} not exists", this.toSqlImpl());
-                throw new 
AnalysisException(getFunctionNotFoundError(collectChildReturnTypes()));
-            }
         } else if (fnName.getFunction().equalsIgnoreCase("array_filter")) {
             if (fnParams.exprs() == null || fnParams.exprs().size() != 2) {
                 throw new AnalysisException("The " + fnName.getFunction() + " 
function must have two params");
@@ -170,11 +167,6 @@ public class LambdaFunctionCallExpr extends 
FunctionCallExpr {
 
             fn = getBuiltinFunction(fnName.getFunction(), argTypes,
                     Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
-            if (fn == null) {
-                LOG.warn("fn {} not exists", this.toSqlImpl());
-                throw new 
AnalysisException(getFunctionNotFoundError(collectChildReturnTypes()));
-            }
-            fn.setReturnType(getChild(0).getType());
         } else if (fnName.getFunction().equalsIgnoreCase("array_sortby")) {
             if (fnParams.exprs() == null || fnParams.exprs().size() < 2) {
                 throw new AnalysisException("The " + fnName.getFunction() + " 
function must have at least two params");
@@ -202,11 +194,6 @@ public class LambdaFunctionCallExpr extends 
FunctionCallExpr {
             }
             fn = getBuiltinFunction(fnName.getFunction(), argTypes,
                     Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
-            if (fn == null) {
-                LOG.warn("fn {} not exists", this.toSqlImpl());
-                throw new 
AnalysisException(getFunctionNotFoundError(collectChildReturnTypes()));
-            }
-            fn.setReturnType(getChild(0).getType());
         } else if (fnName.getFunction().equalsIgnoreCase("array_last")) {
             // 
array_last(lambda,array)--->array_last(array,lambda)--->element_at(array_filter,-1)
             if (getChild(childSize - 1) instanceof LambdaFunctionExpr) {
@@ -227,17 +214,12 @@ public class LambdaFunctionCallExpr extends 
FunctionCallExpr {
             }
             fnName = new FunctionName(null, "element_at");
             fn = getBuiltinFunction(fnName.getFunction(), argTypes, 
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
-            if (fn == null) {
-                LOG.warn("fn element_at not exists");
-                throw new 
AnalysisException(getFunctionNotFoundError(collectChildReturnTypes()));
-            }
-            fn.setReturnType(((ArrayType) argTypes[0]).getItemType());
         }
-        LOG.info("fn string: " + fn.signatureString() + ". return type: " + 
fn.getReturnType());
         if (fn == null) {
             LOG.warn("fn {} not exists", this.toSqlImpl());
             throw new 
AnalysisException(getFunctionNotFoundError(collectChildReturnTypes()));
         }
+        LOG.debug("fn string: " + fn.signatureString() + ". return type: " + 
fn.getReturnType());
         this.type = fn.getReturnType();
     }
 
diff --git a/gensrc/script/doris_builtins_functions.py 
b/gensrc/script/doris_builtins_functions.py
index 451bbd8f95..a81ad078bf 100644
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -631,7 +631,6 @@ visible_functions = [
     [['array_popfront'], 'ARRAY_DECIMAL128', ['ARRAY_DECIMAL128'], ''],
     [['array_popfront'], 'ARRAY_VARCHAR', ['ARRAY_VARCHAR'], ''],
     [['array_popfront'], 'ARRAY_STRING', ['ARRAY_STRING'], ''],
-    [['array_map'], 'ARRAY', ['LAMBDA_FUNCTION', 'ARRAY<K>', '...'], '', 
['K']],
     [['array_filter'], 'ARRAY_BOOLEAN',['ARRAY_BOOLEAN', 'ARRAY_BOOLEAN'], ''],
     [['array_filter'], 'ARRAY_TINYINT',['ARRAY_TINYINT', 'ARRAY_BOOLEAN'], ''],
     [['array_filter'], 'ARRAY_SMALLINT',['ARRAY_SMALLINT', 'ARRAY_BOOLEAN'], 
''],


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to