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

dataroaring 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 941e192019 [enhancement](test) add function case 
date_sub(datetime,INTERVAL dayofmonth(datetime)-1 DAY) (#16306)
941e192019 is described below

commit 941e1920196c2c8378d4179883a632f406a8161c
Author: yongkang.zhong <[email protected]>
AuthorDate: Thu Feb 2 09:56:01 2023 +0800

    [enhancement](test) add function case date_sub(datetime,INTERVAL 
dayofmonth(datetime)-1 DAY) (#16306)
---
 .../datetime_functions/test_date_function.out      |  6 +++++
 .../datetime_functions/test_date_function.groovy   | 28 ++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git 
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
 
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
index 578da53634..563040c4ec 100644
--- 
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
+++ 
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
@@ -606,3 +606,9 @@ true
 2021-12-27     2021-12-27      2021-12-27      2021-12-27
 2022-02-28     2022-02-28      2022-02-28      2022-02-28
 
+-- !sql --
+2022-01-20T00:00       2023-01-20T00:00
+
+-- !sql --
+2022-01-20T00:00       2023-01-20T00:00
+
diff --git 
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
 
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
index 907843dd7e..09472c76d7 100644
--- 
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
@@ -618,4 +618,32 @@ suite("test_date_function") {
                 from ${tableName};
     """
     sql """ DROP TABLE IF EXISTS ${tableName}; """
+
+    // test date_sub(datetime,dayofmonth)
+    sql """ DROP TABLE IF EXISTS ${tableName}; """
+    sql """
+            CREATE TABLE IF NOT EXISTS ${tableName} (
+                birth1 datetime,
+                birth2 datetimev2)
+            UNIQUE KEY(birth1,birth2)
+            DISTRIBUTED BY HASH (birth1,birth2) BUCKETS 1
+            PROPERTIES( "replication_allocation" = "tag.location.default: 1");
+        """
+    sql """
+        insert into ${tableName} values
+        ('2022-01-20 00:00:00', '2023-01-20 00:00:00.123');"""
+    qt_sql """
+        select *  from
+          ${tableName}
+        where
+          birth1 <= date_sub('2023-02-01 10:35:13', INTERVAL 
dayofmonth('2023-02-01 10:35:13')-1 DAY)
+    """
+        qt_sql """
+            select *  from
+              ${tableName}
+            where
+              birth2 <= date_sub('2023-02-01 10:35:13', INTERVAL 
dayofmonth('2023-02-01 10:35:13')-1 DAY)
+        """
+    sql """ DROP TABLE IF EXISTS ${tableName}; """
+
 }


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

Reply via email to