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

morningman 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 4b85c2738e [bug](function)fix potential npe in getFunction() when fe 
restart (#18989)
4b85c2738e is described below

commit 4b85c2738e649d445b27c77e09ab3305e1dbc311
Author: xy720 <[email protected]>
AuthorDate: Thu May 4 23:45:22 2023 +0800

    [bug](function)fix potential npe in getFunction() when fe restart (#18989)
    
    fix potential npe in getFunction() when fe restart
---
 .../main/java/org/apache/doris/catalog/FunctionSet.java   |  3 +--
 .../java/org/apache/doris/catalog/FunctionSetTest.java    | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionSet.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionSet.java
index be8d944423..b633e4ec7c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionSet.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionSet.java
@@ -1290,8 +1290,7 @@ public class FunctionSet<T> {
             if (f.hasTemplateArg()) {
                 f = specializeTemplateFunction(f, desc, 
f.hasVariadicTemplateArg());
             }
-            f = resolveInferenceFunction(f, desc);
-            if (f != null) {
+            if (f != null && (f = resolveInferenceFunction(f, desc)) != null) {
                 inferredFunctions.add(f);
             }
         }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/catalog/FunctionSetTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/catalog/FunctionSetTest.java
index ccdfd46574..737a3f9b40 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/FunctionSetTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/FunctionSetTest.java
@@ -18,7 +18,9 @@
 package org.apache.doris.catalog;
 
 import org.apache.doris.analysis.FunctionName;
+import org.apache.doris.catalog.Function.CompareMode;
 
+import com.google.common.collect.Lists;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -52,4 +54,17 @@ public class FunctionSetTest {
         Assert.assertTrue(newArgTypes[0].matchesType(ScalarType.VARCHAR));
     }
 
+    @Test
+    public void testAddInferenceFunction() {
+        TemplateType type1 = new TemplateType("T");
+        TemplateType type2 = new TemplateType("T");
+        
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltin(
+                "test_a", Type.ANY_TYPE, Lists.newArrayList(type1, type2), 
false,
+                "", "", "", true));
+        Type[] argTypes = {ArrayType.create(), ScalarType.INT};
+        Function desc = new Function(new FunctionName("test_a"), 
Arrays.asList(argTypes), ScalarType.INVALID, false);
+        Function result = functionSet.getFunction(desc, 
CompareMode.IS_IDENTICAL);
+        Assert.assertNull(result);
+    }
+
 }


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

Reply via email to