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/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 7792aebd21 [test]add conditional function test case (#9913)
7792aebd21 is described below

commit 7792aebd21d0ecad292d9914e56ce0831e92af37
Author: zy-kkk <[email protected]>
AuthorDate: Thu Jun 2 14:52:03 2022 +0800

    [test]add conditional function test case (#9913)
    
    * add conditional function test case
    
    * Update test_conditional_function.groovy
    
    Delete useless code
    
    * optimize the code
---
 .../test_conditional_function.out                  | 40 +++++++++++++++++
 .../test_conditional_function.groovy               | 52 ++++++++++++++++++++++
 2 files changed, 92 insertions(+)

diff --git 
a/regression-test/data/query/sql_functions/conditional_functions/test_conditional_function.out
 
b/regression-test/data/query/sql_functions/conditional_functions/test_conditional_function.out
new file mode 100644
index 0000000000..760b515996
--- /dev/null
+++ 
b/regression-test/data/query/sql_functions/conditional_functions/test_conditional_function.out
@@ -0,0 +1,40 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+0
+
+-- !sql --
+0
+
+-- !sql --
+1      user_id = 1
+2      user_id = 2
+3      user_id not exist
+4      user_id not exist
+
+-- !sql --
+1      user_id = 1
+2      user_id = 2
+3      user_id not exist
+4      user_id not exist
+
+-- !sql --
+1      true
+2      false
+3      false
+4      false
+
+-- !sql --
+1111
+
+-- !sql --
+1
+
+-- !sql --
+10
+
+-- !sql --
+\N
+
+-- !sql --
+1
+
diff --git 
a/regression-test/suites/query/sql_functions/conditional_functions/test_conditional_function.groovy
 
b/regression-test/suites/query/sql_functions/conditional_functions/test_conditional_function.groovy
new file mode 100644
index 0000000000..3859d71b95
--- /dev/null
+++ 
b/regression-test/suites/query/sql_functions/conditional_functions/test_conditional_function.groovy
@@ -0,0 +1,52 @@
+// 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.
+
+suite("test_conditional_function", "query") {
+    qt_sql "set enable_vectorized_engine = true;"
+    qt_sql "set batch_size = 4096;"
+
+    def tbName = "test_conditional_function"
+    sql "DROP TABLE IF EXISTS ${tbName};"
+    sql """
+            CREATE TABLE IF NOT EXISTS ${tbName} (
+                user_id INT
+            )
+            DISTRIBUTED BY HASH(user_id) BUCKETS 5 
properties("replication_num" = "1");
+        """
+    sql """
+        INSERT INTO ${tbName} VALUES 
+            (1),
+            (2),
+            (3),
+            (4);
+        """
+    qt_sql "select user_id, case user_id when 1 then 'user_id = 1' when 2 then 
'user_id = 2' else 'user_id not exist' end test_case from ${tbName} order by 
user_id;"
+    qt_sql "select user_id, case when user_id = 1 then 'user_id = 1' when 
user_id = 2 then 'user_id = 2' else 'user_id not exist' end test_case from 
${tbName} order by user_id;"
+
+    qt_sql "select user_id, if(user_id = 1, \"true\", \"false\") test_if from 
${tbName} order by user_id;"
+
+    sql "DROP TABLE ${tbName};"
+
+    qt_sql "select coalesce(NULL, '1111', '0000');"
+
+    qt_sql "select ifnull(1,0);"
+    qt_sql "select ifnull(null,10);"
+
+    qt_sql "select nullif(1,1);"
+    qt_sql "select nullif(1,0);"
+
+}


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

Reply via email to