zhannngchen commented on code in PR #25884:
URL: https://github.com/apache/doris/pull/25884#discussion_r1374328664


##########
regression-test/suites/nereids_p0/insert_into_table/update_on_current_timestamp.groovy:
##########
@@ -0,0 +1,174 @@
+// 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("nereids_update_on_current_timestamp") {
+    sql 'set experimental_enable_nereids_planner=true'
+    sql 'set enable_fallback_to_original_planner=false'
+    sql 'set enable_nereids_dml=true'
+    sql "sync;"
+
+
+    def t1 = "nereids_update_on_current_timestamp1"
+    sql """ DROP TABLE IF EXISTS ${t1};"""
+    sql """ CREATE TABLE ${t1} (
+                `id` int(11) NOT NULL COMMENT "用户 ID",
+                `name` varchar(65533) DEFAULT "unknown" COMMENT "用户姓名",
+                `score` int(11) NOT NULL COMMENT "用户得分",
+                `test` int(11) NULL COMMENT "null test",
+                `dft` int(11) DEFAULT "4321",
+                `update_time` datetime default current_timestamp on update 
current_timestamp,
+                `update_time2` datetime(6) default current_timestamp(5) on 
update current_timestamp(5))
+            UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 1
+            PROPERTIES(
+                "replication_num" = "1",
+                "enable_unique_key_merge_on_write" = "true"
+            );"""
+    
+    def res = sql "show create table ${t1};"
+    assertTrue(res.toString().containsIgnoreCase("`update_time` datetime NULL 
DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
+    assertTrue(res.toString().containsIgnoreCase("`update_time2` datetime(6) 
NULL DEFAULT CURRENT_TIMESTAMP(5) ON UPDATE CURRENT_TIMESTAMP(5)"))
+    
+    // set enable_unique_key_partial_update=false, it's a row update
+    sql "set enable_unique_key_partial_update=false;"
+    sql "sync;"
+    sql """ insert into ${t1}(id,name,score,test,dft) values
+            (2, "doris2", 2000, 223, 1),
+            (1, "doris", 1000, 123, 1);"""
+    qt_sql "select id,name,score,test,dft from ${t1} order by id;"
+    qt_sql "select count(distinct update_time) from ${t1} where update_time > 
'2023-10-01 00:00:00';"
+    qt_sql "select count(distinct update_time2) from ${t1} where update_time2 
> '2023-10-01 00:00:00';"
+
+
+    // set enable_unique_key_partial_update=true, it's a partial update
+    // don't specify the `update_time` column
+    // it will be automatically updated to current_timestamp()
+    sql "set enable_unique_key_partial_update=true;"
+    sql "set enable_insert_strict=false;"
+    sql "sync;"
+    sql """ insert into ${t1}(id, score) values

Review Comment:
   also add a case for `update` statement



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to