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

liyang pushed a commit to branch kylin5
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit d2176edd575f51c8a05f06d0f476f93644306b5f
Author: jlf <longfei.ji...@kyligence.io>
AuthorDate: Thu Nov 2 15:43:47 2023 +0800

    KYLIN-5864 Fix the query functions `ifnull` and `substring`
---
 pom.xml                                            |  2 +-
 .../org/apache/kylin/common/KylinConfigBase.java   |  1 -
 .../org/apache/kylin/query/udf/SparkOtherUDF.java  |  5 ++
 .../kylin/query/udf/nullHandling/IfNullUDF.java    | 58 ----------------------
 .../kylin/query/udf/NullHandlingUDFTest.java       | 39 ---------------
 .../kylin/query/runtime/ExpressionConverter.scala  |  2 +-
 6 files changed, 7 insertions(+), 100 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5244534890..8c1883868c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -138,7 +138,7 @@
         <scala-retry>0.3.0</scala-retry>
 
         <!-- Calcite Version -->
-        <calcite.version>1.116.0-kylin-4.x-r036</calcite.version>
+        <calcite.version>1.116.0-kylin-4.x-r037</calcite.version>
         <avatica.version>4.x_1.10-r01</avatica.version>
 
         <!-- Hadoop Common deps, keep compatible with hadoop2.version -->
diff --git 
a/src/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java 
b/src/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
index 04a39029ff..ecd74eb9d5 100644
--- a/src/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
+++ b/src/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
@@ -2167,7 +2167,6 @@ public abstract class KylinConfigBase implements 
Serializable {
         udfMap.put("to_char", 
"org.apache.kylin.query.udf.formatUdf.ToCharUDF");
         udfMap.put("instr", "org.apache.kylin.query.udf.stringUdf.InStrUDF");
         udfMap.put("strpos", "org.apache.kylin.query.udf.stringUdf.StrPosUDF");
-        udfMap.put("ifnull", 
"org.apache.kylin.query.udf.nullHandling.IfNullUDF");
         udfMap.put("nvl", "org.apache.kylin.query.udf.nullHandling.NvlUDF");
         udfMap.put("isnull", 
"org.apache.kylin.query.udf.nullHandling.IsNullUDF");
         udfMap.put("split_part", 
"org.apache.kylin.query.udf.stringUdf.SplitPartUDF");
diff --git 
a/src/query/src/main/java/org/apache/kylin/query/udf/SparkOtherUDF.java 
b/src/query/src/main/java/org/apache/kylin/query/udf/SparkOtherUDF.java
index 469ecd47fe..d7f3037090 100644
--- a/src/query/src/main/java/org/apache/kylin/query/udf/SparkOtherUDF.java
+++ b/src/query/src/main/java/org/apache/kylin/query/udf/SparkOtherUDF.java
@@ -27,4 +27,9 @@ public class SparkOtherUDF implements NotConstant {
     public Object EXPLODE(@Parameter(name = "t1") Object exp1) throws 
CalciteNotSupportException {
         throw new CalciteNotSupportException();
     }
+
+    public Object IFNULL(@Parameter(name = "left") Object left, 
@Parameter(name = "right") Object right)
+            throws CalciteNotSupportException {
+        throw new CalciteNotSupportException();
+    }
 }
diff --git 
a/src/query/src/main/java/org/apache/kylin/query/udf/nullHandling/IfNullUDF.java
 
b/src/query/src/main/java/org/apache/kylin/query/udf/nullHandling/IfNullUDF.java
deleted file mode 100644
index 73b6597950..0000000000
--- 
a/src/query/src/main/java/org/apache/kylin/query/udf/nullHandling/IfNullUDF.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.kylin.query.udf.nullHandling;
-
-import java.sql.Date;
-import java.sql.Timestamp;
-
-import org.apache.calcite.linq4j.function.Parameter;
-
-public class IfNullUDF {
-
-    public String IFNULL(@Parameter(name = "str1") String expression1, 
@Parameter(name = "str2") String expression2) {
-        return expression1 == null ? expression2 : expression1;
-    }
-
-    public Integer IFNULL(@Parameter(name = "num1") Integer expression1,
-            @Parameter(name = "num2") Integer expression2) {
-        return expression1 == null ? expression2 : expression1;
-    }
-
-    public Double IFNULL(@Parameter(name = "num1") Double expression1, 
@Parameter(name = "num2") Double expression2) {
-        return expression1 == null ? expression2 : expression1;
-    }
-
-    public Date IFNULL(@Parameter(name = "date1") Date expression1, 
@Parameter(name = "date2") Date expression2) {
-        return expression1 == null ? expression2 : expression1;
-    }
-
-    public Timestamp IFNULL(@Parameter(name = "date1") Timestamp expression1,
-            @Parameter(name = "date2") Timestamp expression2) {
-        return expression1 == null ? expression2 : expression1;
-    }
-
-    public Boolean IFNULL(@Parameter(name = "num1") Boolean expression1,
-            @Parameter(name = "num2") Boolean expression2) {
-        return expression1 == null ? expression2 : expression1;
-    }
-
-    public Long IFNULL(@Parameter(name = "num1") Long expression1, 
@Parameter(name = "num2") Long expression2) {
-        return expression1 == null ? expression2 : expression1;
-    }
-}
diff --git 
a/src/query/src/test/java/org/apache/kylin/query/udf/NullHandlingUDFTest.java 
b/src/query/src/test/java/org/apache/kylin/query/udf/NullHandlingUDFTest.java
index c841b211bb..8f3e611534 100644
--- 
a/src/query/src/test/java/org/apache/kylin/query/udf/NullHandlingUDFTest.java
+++ 
b/src/query/src/test/java/org/apache/kylin/query/udf/NullHandlingUDFTest.java
@@ -18,56 +18,17 @@
 
 package org.apache.kylin.query.udf;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.sql.Date;
 import java.sql.Timestamp;
 
-import org.apache.kylin.query.udf.nullHandling.IfNullUDF;
 import org.apache.kylin.query.udf.nullHandling.IsNullUDF;
 import org.junit.Test;
 
 public class NullHandlingUDFTest {
 
-    @Test
-    public void testIfNullUDF() throws Exception {
-        IfNullUDF ifNullUDF = new IfNullUDF();
-
-        String str1 = ifNullUDF.IFNULL("Apache", "Kylin");
-        assertEquals("Apache", str1);
-        String str2 = ifNullUDF.IFNULL(null, "Kylin");
-        assertEquals("Kylin", str2);
-
-        double d1 = ifNullUDF.IFNULL(2.3, 2.4);
-        assertEquals(d1, 2.3, 0);
-        double d2 = ifNullUDF.IFNULL(null, 2.4);
-        assertEquals(d2, 2.4, 0);
-
-        int num1 = ifNullUDF.IFNULL(23, 24);
-        assertEquals(num1, 23);
-        int num2 = ifNullUDF.IFNULL(null, 24);
-        assertEquals(num2, 24);
-
-        Date date1 = new Date(System.currentTimeMillis());
-        Date date2 = new Date(System.currentTimeMillis());
-        Date date3 = ifNullUDF.IFNULL(date1, date2);
-        assertEquals(date3, date1);
-        Date date4 = ifNullUDF.IFNULL(null, date2);
-        assertEquals(date4, date2);
-
-        Timestamp timestamp1 = new Timestamp(System.currentTimeMillis());
-        Timestamp timestamp2 = new Timestamp(System.currentTimeMillis());
-        Timestamp timestamp3 = ifNullUDF.IFNULL(timestamp1, timestamp2);
-        assertEquals(timestamp3, timestamp1);
-        Timestamp timestamp4 = ifNullUDF.IFNULL(null, timestamp2);
-        assertEquals(timestamp4, timestamp2);
-
-        assertTrue(ifNullUDF.IFNULL(true, false));
-        assertFalse(ifNullUDF.IFNULL(null, false));
-    }
-
     @Test
     public void testIsNullUDF() throws Exception {
         IsNullUDF isNullUDF = new IsNullUDF();
diff --git 
a/src/spark-project/sparder/src/main/scala/org/apache/kylin/query/runtime/ExpressionConverter.scala
 
b/src/spark-project/sparder/src/main/scala/org/apache/kylin/query/runtime/ExpressionConverter.scala
index 5a26ebaf8a..0967850210 100644
--- 
a/src/spark-project/sparder/src/main/scala/org/apache/kylin/query/runtime/ExpressionConverter.scala
+++ 
b/src/spark-project/sparder/src/main/scala/org/apache/kylin/query/runtime/ExpressionConverter.scala
@@ -47,7 +47,7 @@ object ExpressionConverter {
 
   private val ternaryParameterFunc = mutable.HashSet("replace", 
"substring_index", "conv", "regexp_extract")
   private val binaryParameterFunc =
-    mutable.HashSet("decode", "encode", "find_in_set", "levenshtein", "sha2",
+    mutable.HashSet("decode", "encode", "find_in_set", "levenshtein", "sha2", 
"ifnull",
       "trunc", "add_months", "date_add", "date_sub", "from_utc_timestamp", 
"to_utc_timestamp", "date_format",
       // math function
       "hypot", "log"

Reply via email to