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

zhangstar333 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 c60c8f57cd5 [fix](function) Fix wrong nullable processing for 
convert_tz (#38764)
c60c8f57cd5 is described below

commit c60c8f57cd5736c734e56072cc4fc96e9a3c36c0
Author: zclllhhjj <zhaochan...@selectdb.com>
AuthorDate: Mon Aug 5 11:40:47 2024 +0800

    [fix](function) Fix wrong nullable processing for convert_tz (#38764)
    
    ## Proposed changes
    
    Issue Number: close #xxx
    
    This pr make `convert_tz` use default nullity processing logic rather
    than `update_null_map` manually to get correct result. The bug of
    `update_null_map` will be fixed by
    https://github.com/apache/doris/pull/38787
    
    before:
    ```sql
    mysql> select convert_tz(dt, '+00:00', IF(property_value IS NULL, '+00:00', 
property_value)) from cvt_tz;
    
+--------------------------------------------------------------------------------+
    | convert_tz(dt, '+00:00', if(property_value IS NULL, '+00:00', 
property_value)) |
    
+--------------------------------------------------------------------------------+
    | 2024-04-18 23:20:00                                                       
     |
    |                                                                           
     |
    |                                                                           
     |
    | 2024-04-18 23:20:00                                                       
     |
    |                                                                           
     |
    |                                                                           
     |
    | 2024-04-18 23:20:00                                                       
     |
    |                                                                           
     |
    | 2024-04-18 23:20:00                                                       
     |
    |                                                                           
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    |                                                                           
     |
    |                                                                           
     |
    | 2024-04-18 23:20:00                                                       
     |
    |                                                                           
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    |                                                                           
     |
    | 2024-04-18 23:20:00                                                       
     |
    
+--------------------------------------------------------------------------------+
    ```
    
    after:
    ```sql
    mysql> select convert_tz(dt, '+00:00', IF(property_value IS NULL, '+00:00', 
property_value)) from cvt_tz;
    
+--------------------------------------------------------------------------------+
    | convert_tz(dt, '+00:00', if(property_value IS NULL, '+00:00', 
property_value)) |
    
+--------------------------------------------------------------------------------+
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    | 2024-04-18 23:20:00                                                       
     |
    
+--------------------------------------------------------------------------------+
    ```
---
 be/src/vec/functions/function_convert_tz.h         | 10 ------
 .../datetime_functions/test_convert_tz.out         | 23 ++++++++++++++
 .../datetime_functions/test_convert_tz.groovy      | 37 ++++++++++++++++++++++
 3 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/be/src/vec/functions/function_convert_tz.h 
b/be/src/vec/functions/function_convert_tz.h
index c9739c2e9be..af118c80583 100644
--- a/be/src/vec/functions/function_convert_tz.h
+++ b/be/src/vec/functions/function_convert_tz.h
@@ -88,12 +88,6 @@ public:
                 std::make_shared<DataTypeString>()};
     }
 
-    bool use_default_implementation_for_nulls() const override { return false; 
}
-
-    Status close(FunctionContext* context, FunctionContext::FunctionStateScope 
scope) override {
-        return Status::OK();
-    }
-
     Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
                         size_t result, size_t input_rows_count) const override 
{
         auto result_null_map_column = ColumnUInt8::create(input_rows_count, 0);
@@ -110,10 +104,6 @@ public:
 
         default_preprocess_parameter_columns(argument_columns, col_const, {1, 
2}, block, arguments);
 
-        for (int i = 0; i < 3; i++) {
-            check_set_nullable(argument_columns[i], result_null_map_column, 
col_const[i]);
-        }
-
         if (col_const[1] && col_const[2]) {
             auto result_column = ColumnType::create();
             execute_tz_const(context, assert_cast<const 
ColumnType*>(argument_columns[0].get()),
diff --git 
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_convert_tz.out
 
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_convert_tz.out
new file mode 100644
index 00000000000..9bf49bd74ef
--- /dev/null
+++ 
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_convert_tz.out
@@ -0,0 +1,23 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql1 --
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+2024-04-18T23:20
+
diff --git 
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_convert_tz.groovy
 
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_convert_tz.groovy
new file mode 100644
index 00000000000..2959c7f136b
--- /dev/null
+++ 
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_convert_tz.groovy
@@ -0,0 +1,37 @@
+// 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_convert_tz") {
+    sql """
+        CREATE TABLE `cvt_tz` (
+            `rowid` int NULL,
+            `dt` datetime NULL,
+            `property_value` varchar(65533) NULL
+        ) ENGINE=OLAP
+        DUPLICATE KEY(`rowid`, `dt`, `property_value`)
+        DISTRIBUTED BY HASH(`rowid`) BUCKETS 10
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+
+    sql """insert into cvt_tz select number, "2024-04-18 23:20:00", NULL from 
numbers("number" = "20"); """
+
+    order_qt_sql1 """
+        select convert_tz(dt, '+00:00', IF(property_value IS NULL, '+00:00', 
property_value)) from cvt_tz
+    """
+}
\ No newline at end of file


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

Reply via email to