[branch-2.1](function) Fix unexpected result of unix_timestamp when input is out of bound (#49430) (#50609)
pick https://github.com/apache/doris/pull/49430 but removed be-ut because we can't. Co-authored-by: Pxl <xl@selectdb.com>
This commit is contained in:
@ -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";
|
||||
|
||||
@ -346,10 +346,10 @@ February
|
||||
1196389819
|
||||
|
||||
-- !sql_ustamp2 --
|
||||
1196389819
|
||||
1196389819.000000
|
||||
|
||||
-- !sql_ustamp3 --
|
||||
1196389819
|
||||
1196389819.000000
|
||||
|
||||
-- !sql_ustamp4 --
|
||||
0
|
||||
@ -363,6 +363,12 @@ February
|
||||
-- !sql_ustamp7 --
|
||||
1196389819.1235
|
||||
|
||||
-- !sql_ustamp8 --
|
||||
0.000
|
||||
|
||||
-- !sql_ustamp9 --
|
||||
0
|
||||
|
||||
-- !sql --
|
||||
0
|
||||
|
||||
@ -664,11 +670,11 @@ true
|
||||
2023-08-17T17:41:18
|
||||
|
||||
-- !sql_dt_null_1 --
|
||||
1607702400.0000 1607702400 1607702400 1607702400 1607702400
|
||||
1607746332.0000 1607746332 1607702400 1607702400 1607746332
|
||||
1607746332.0000 1607746332 1607702400 1607702400 1607746332
|
||||
1607746332.1230 1607746332 1607702400 1607702400 1607746332
|
||||
1607746332.6667 1607746333 1607702400 1607702400 1607746333
|
||||
1607702400.0000 1607702400 1607702400 1607702400 1607702400.000000
|
||||
1607746332.0000 1607746332 1607702400 1607702400 1607746332.000000
|
||||
1607746332.0000 1607746332 1607702400 1607702400 1607746332.000000
|
||||
1607746332.1230 1607746332 1607702400 1607702400 1607746332.123000
|
||||
1607746332.6667 1607746333 1607702400 1607702400 1607746332.666666
|
||||
|
||||
-- !sql_time_value --
|
||||
1 00:00:00 0 0 0
|
||||
|
||||
@ -382,6 +382,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 """
|
||||
|
||||
Reference in New Issue
Block a user