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


The following commit(s) were added to refs/heads/master by this push:
     new 73d4cd9508d [fix](function) fix function sec_to_time max error (#55900)
73d4cd9508d is described below

commit 73d4cd9508dd1615f1bb677bcb13b741ca4c0e82
Author: dwdwqfwe <[email protected]>
AuthorDate: Fri Sep 12 09:01:44 2025 +0800

    [fix](function) fix function sec_to_time max error (#55900)
    
    ### What problem does this PR solve?
    mysql> select SEC_TO_TIME(76202185) ;
    +-----------------------+
    | SEC_TO_TIME(76202185) |
    +-----------------------+
    | 839:59:59             |
    +-----------------------+
    
    max time should be  838:59:59
    
    
    Issue Number: close #xxx
    
    Related PR: #xxx
    
    Problem Summary:
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [ ] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [ ] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 be/src/vec/runtime/time_value.h                         |   4 ++--
 regression-test/data/correctness/test_time_function.out | Bin 447 -> 502 bytes
 .../suites/correctness/test_time_function.groovy        |   7 +++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/runtime/time_value.h b/be/src/vec/runtime/time_value.h
index 541e365813c..17614429947 100644
--- a/be/src/vec/runtime/time_value.h
+++ b/be/src/vec/runtime/time_value.h
@@ -42,8 +42,8 @@ public:
     constexpr static int64_t ONE_MINUTE_SECONDS = 60;
     constexpr static int64_t ONE_HOUR_SECONDS = 60 * ONE_MINUTE_SECONDS;
     constexpr static uint32_t MICROS_SCALE = 6;
-    constexpr static int64_t MAX_TIME =
-            3024000LL * ONE_SECOND_MICROSECONDS - 1; // 840:00:00 - 1ms -> 
838:59:59.999999
+    constexpr static int64_t MAX_TIME = 838 * ONE_HOUR_MICROSECONDS + 59 * 
ONE_MINUTE_MICROSECONDS +
+                                        59 * ONE_SECOND_MICROSECONDS + 999999; 
// 838:59:59.999999
 
     /// TODO: Why is the time type stored as double? Can we directly use int64 
and remove the time limit?
     using TimeType = typename PrimitiveTypeTraits<TYPE_TIMEV2>::CppType; // 
double
diff --git a/regression-test/data/correctness/test_time_function.out 
b/regression-test/data/correctness/test_time_function.out
index 84c22e1f309..5c15a86c1ab 100644
Binary files a/regression-test/data/correctness/test_time_function.out and 
b/regression-test/data/correctness/test_time_function.out differ
diff --git a/regression-test/suites/correctness/test_time_function.groovy 
b/regression-test/suites/correctness/test_time_function.groovy
index 2a7bea32fe7..6cb3f1cc49a 100644
--- a/regression-test/suites/correctness/test_time_function.groovy
+++ b/regression-test/suites/correctness/test_time_function.groovy
@@ -73,4 +73,11 @@ suite("test_time_function") {
     qt_select """
         select time_to_sec(timediff('2024-01-22', '2024-01-15')) as seconds;
     """
+
+    qt_maxtime1 """
+        select SEC_TO_TIME(762021855) ;
+    """
+    qt_maxtime2 """
+        select SEC_TO_TIME(-762021855) ;
+    """
 }


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

Reply via email to