This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new b4a80b294d1 [branch-3.0](function) Fix unexpected result of
unix_timestamp when input is out of bound (#49430) (#50610)
b4a80b294d1 is described below
commit b4a80b294d1e01c6f1e745802af664784747da41
Author: zclllyybb <[email protected]>
AuthorDate: Wed May 7 14:31:39 2025 +0800
[branch-3.0](function) Fix unexpected result of unix_timestamp when input
is out of bound (#49430) (#50610)
pick https://github.com/apache/doris/pull/49430 but removed be-ut
because we can't.
Co-authored-by: Pxl <[email protected]>
---
be/src/vec/functions/function_timestamp.cpp | 3 +--
.../datetime_functions/test_date_function.out | Bin 9900 -> 9997 bytes
.../datetime_functions/test_date_function.groovy | 4 ++++
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/functions/function_timestamp.cpp
b/be/src/vec/functions/function_timestamp.cpp
index fb3c78bbb9f..a0d6328a6a7 100644
--- a/be/src/vec/functions/function_timestamp.cpp
+++ b/be/src/vec/functions/function_timestamp.cpp
@@ -673,8 +673,7 @@ struct UnixTimeStampDateImpl {
ts_value.unix_timestamp(×tamp,
context->state()->timezone_obj());
DCHECK(valid);
- auto& [sec, ms] = timestamp;
- sec = UnixTimeStampImpl::trim_timestamp(sec);
+ auto [sec, ms] = UnixTimeStampImpl::trim_timestamp(timestamp);
auto ms_str = std::to_string(ms).substr(0, scale);
if (ms_str.empty()) {
ms_str = "0";
diff --git
a/regression-test/data/nereids_p0/sql_functions/datetime_functions/test_date_function.out
b/regression-test/data/nereids_p0/sql_functions/datetime_functions/test_date_function.out
index 2aef8a1257a..c153d73b9e3 100644
Binary files
a/regression-test/data/nereids_p0/sql_functions/datetime_functions/test_date_function.out
and
b/regression-test/data/nereids_p0/sql_functions/datetime_functions/test_date_function.out
differ
diff --git
a/regression-test/suites/nereids_p0/sql_functions/datetime_functions/test_date_function.groovy
b/regression-test/suites/nereids_p0/sql_functions/datetime_functions/test_date_function.groovy
index d57139eebbc..42a09919cf9 100644
---
a/regression-test/suites/nereids_p0/sql_functions/datetime_functions/test_date_function.groovy
+++
b/regression-test/suites/nereids_p0/sql_functions/datetime_functions/test_date_function.groovy
@@ -385,6 +385,10 @@ suite("test_date_function") {
qt_sql_ustamp5 """ select unix_timestamp('2007-11-30 10:30:19.123456') """
qt_sql_ustamp6 """ select unix_timestamp(cast('2007-11-30 10:30:19.123456'
as datetimev2(3))) """
qt_sql_ustamp7 """ select unix_timestamp(cast('2007-11-30 10:30:19.123456'
as datetimev2(4))) """
+ qt_sql_ustamp8 """ SELECT UNIX_TIMESTAMP('9999-12-30 23:59:59.999'); """
+ qt_sql_ustamp9 """ SELECT UNIX_TIMESTAMP('9999-12-30 23:59:59'); """
+ testFoldConst("SELECT UNIX_TIMESTAMP('9999-12-30 23:59:59.999');")
+ testFoldConst("SELECT UNIX_TIMESTAMP('9999-12-30 23:59:59');")
// UTC_TIMESTAMP
def utc_timestamp_str = sql """ select utc_timestamp(),utc_timestamp() + 1
"""
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]