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

gabriellee 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 ef95e962c7e [fix](timev2) fix Type not implemented in fold by be 
(#26478)
ef95e962c7e is described below

commit ef95e962c7e4622caed3550800231e18c9c6ed6c
Author: Mryange <[email protected]>
AuthorDate: Tue Nov 7 17:25:20 2023 +0800

    [fix](timev2) fix Type not implemented in fold by be (#26478)
---
 be/src/runtime/fold_constant_executor.cpp          |  5 ++++
 .../data/correctness/test_timev2_fold.out          | 13 ++++++++
 .../suites/correctness/test_timev2_fold.groovy     | 35 ++++++++++++++++++++++
 3 files changed, 53 insertions(+)

diff --git a/be/src/runtime/fold_constant_executor.cpp 
b/be/src/runtime/fold_constant_executor.cpp
index e5fd16418d6..c3dd21406ef 100644
--- a/be/src/runtime/fold_constant_executor.cpp
+++ b/be/src/runtime/fold_constant_executor.cpp
@@ -195,6 +195,11 @@ string FoldConstantExecutor::_get_result(void* src, size_t 
size, const TypeDescr
         double val = *reinterpret_cast<double*>(src);
         return fmt::format("{}", val);
     }
+    case TYPE_TIMEV2: {
+        constexpr static auto ratio_to_time = (1000 * 1000);
+        double val = *reinterpret_cast<double*>(src);
+        return fmt::format("{}", val / ratio_to_time);
+    }
     case TYPE_CHAR:
     case TYPE_VARCHAR:
     case TYPE_STRING:
diff --git a/regression-test/data/correctness/test_timev2_fold.out 
b/regression-test/data/correctness/test_timev2_fold.out
new file mode 100644
index 00000000000..b070f10507f
--- /dev/null
+++ b/regression-test/data/correctness/test_timev2_fold.out
@@ -0,0 +1,13 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select1 --
+-07:00:00
+
+-- !select2 --
+-07:00:00
+
+-- !select3 --
+-07:00:00
+
+-- !select4 --
+-07:00:00
+
diff --git a/regression-test/suites/correctness/test_timev2_fold.groovy 
b/regression-test/suites/correctness/test_timev2_fold.groovy
new file mode 100644
index 00000000000..8ce05765162
--- /dev/null
+++ b/regression-test/suites/correctness/test_timev2_fold.groovy
@@ -0,0 +1,35 @@
+// 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_timev2_fold") {
+    sql """ set enable_nereids_planner=false,enable_fold_constant_by_be=false 
"""
+    qt_select1 """
+        select timediff( convert_tz("2020-05-05 00:00:00", 'UTC', 
'America/Los_Angeles'), "2020-05-05 00:00:00");
+    """
+    sql """ set enable_nereids_planner=true,enable_fold_constant_by_be=false 
"""
+    qt_select2 """
+        select timediff( convert_tz("2020-05-05 00:00:00", 'UTC', 
'America/Los_Angeles'), "2020-05-05 00:00:00");
+    """
+    sql """ set enable_nereids_planner=false,enable_fold_constant_by_be=true 
"""
+    qt_select3 """
+        select timediff( convert_tz("2020-05-05 00:00:00", 'UTC', 
'America/Los_Angeles'), "2020-05-05 00:00:00");
+    """
+    sql """ set enable_nereids_planner=true,enable_fold_constant_by_be=true """
+    qt_select4 """
+        select timediff( convert_tz("2020-05-05 00:00:00", 'UTC', 
'America/Los_Angeles'), "2020-05-05 00:00:00");
+    """
+}
\ No newline at end of file


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

Reply via email to