You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ni...@apache.org on 2019/06/26 11:27:23 UTC

[kylin] 01/02: KYLIN-4041 CONCAT NULL not working properly

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

nic pushed a commit to branch 2.6.x
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit bdd8e504f023d6795ce605c6e09f74cb65f3a0b8
Author: Yifei.Wu <va...@gmail.com>
AuthorDate: Wed Jun 12 15:27:16 2019 +0800

    KYLIN-4041 CONCAT NULL not working properly
---
 .../resources/query/sql_verifyContent/query02.sql  | 36 ++++++++++++++++++++++
 .../sql_verifyContent/query02.sql.expected.xml     |  4 +++
 .../java/org/apache/kylin/query/udf/ConcatUDF.java |  6 ++++
 3 files changed, 46 insertions(+)

diff --git a/kylin-it/src/test/resources/query/sql_verifyContent/query02.sql b/kylin-it/src/test/resources/query/sql_verifyContent/query02.sql
new file mode 100644
index 0000000..df7a202
--- /dev/null
+++ b/kylin-it/src/test/resources/query/sql_verifyContent/query02.sql
@@ -0,0 +1,36 @@
+--
+-- 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.
+--
+
+-- This is a sample case
+
+
+select
+ concat(meta_categ_name, CAST(null as VARCHAR)) as c1,
+
+ from test_kylin_fact
+ left JOIN edw.test_cal_dt as test_cal_dt
+ ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt
+ left JOIN test_category_groupings
+ ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id
+ left JOIN edw.test_sites as test_sites
+ ON test_kylin_fact.lstg_site_id = test_sites.site_id
+
+ where meta_categ_name = 'Computers'
+ group by meta_categ_name
+ order by meta_categ_name
+ limit 1
\ No newline at end of file
diff --git a/kylin-it/src/test/resources/query/sql_verifyContent/query02.sql.expected.xml b/kylin-it/src/test/resources/query/sql_verifyContent/query02.sql.expected.xml
new file mode 100644
index 0000000..580c0ee
--- /dev/null
+++ b/kylin-it/src/test/resources/query/sql_verifyContent/query02.sql.expected.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<dataset>
+    <expect/>
+</dataset>
\ No newline at end of file
diff --git a/query/src/main/java/org/apache/kylin/query/udf/ConcatUDF.java b/query/src/main/java/org/apache/kylin/query/udf/ConcatUDF.java
index 9c0da53..42946a2 100644
--- a/query/src/main/java/org/apache/kylin/query/udf/ConcatUDF.java
+++ b/query/src/main/java/org/apache/kylin/query/udf/ConcatUDF.java
@@ -23,6 +23,12 @@ import org.apache.calcite.linq4j.function.Parameter;
 public class ConcatUDF {
 
     public String eval(@Parameter(name = "str1") String col1, @Parameter(name = "str2") String col2) {
+        if (col1 == null) {
+            return null;
+        }
+        if (col2 == null) {
+            return null;
+        }
         return col1 + col2;
     }
 }