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 65051d67cf [fix](yearweek) fixed the yearweek result error when mode
is set to 1 (#12234)
65051d67cf is described below
commit 65051d67cf26f4327f395e964e13e007c6d81d10
Author: luozenglin <[email protected]>
AuthorDate: Thu Sep 1 09:46:38 2022 +0800
[fix](yearweek) fixed the yearweek result error when mode is set to 1
(#12234)
---
be/src/vec/runtime/vdatetime_value.cpp | 2 +-
.../datetime_functions/test_date_function.out | 24 ++++++++++++++++++++++
.../datetime_functions/test_date_function.groovy | 8 ++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/be/src/vec/runtime/vdatetime_value.cpp
b/be/src/vec/runtime/vdatetime_value.cpp
index 2a7cbe737c..5ac700d111 100644
--- a/be/src/vec/runtime/vdatetime_value.cpp
+++ b/be/src/vec/runtime/vdatetime_value.cpp
@@ -912,7 +912,7 @@ uint32_t VecDateTimeValue::year_week(uint8_t mode) const {
// not covered by year_week_table, calculate at runtime
uint32_t year = 0;
// The range of the week in the year_week is 1-53, so the mode WEEK_YEAR
is always true.
- uint8_t week = calc_week(*this, mode | 2, &year);
+ uint8_t week = calc_week(*this, mode | 2, &year, true);
// When the mode WEEK_FIRST_WEEKDAY is not set,
// the week in which the last three days of the year fall may belong to
the following year.
if (week == 53 && day() >= 29 && !(mode & 4)) {
diff --git
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
index 1d6f5de323..b6c261cb03 100644
---
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
+++
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
@@ -287,6 +287,30 @@ February
-- !sql --
202026
+-- !sql --
+198912
+
+-- !sql --
+198912
+
+-- !sql --
+198912
+
+-- !sql --
+198912
+
+-- !sql --
+198912
+
+-- !sql --
+198912
+
+-- !sql --
+198912
+
+-- !sql --
+198912
+
-- !sql --
200
diff --git
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
index baf8d83ac8..7b2894c3f6 100644
---
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
+++
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
@@ -249,6 +249,14 @@ suite("test_date_function") {
// YEARWEEK
qt_sql """ select yearweek('2021-1-1') """
qt_sql """ select yearweek('2020-7-1') """
+ qt_sql """ select yearweek('1989-03-21', 0) """
+ qt_sql """ select yearweek('1989-03-21', 1) """
+ qt_sql """ select yearweek('1989-03-21', 2) """
+ qt_sql """ select yearweek('1989-03-21', 3) """
+ qt_sql """ select yearweek('1989-03-21', 4) """
+ qt_sql """ select yearweek('1989-03-21', 5) """
+ qt_sql """ select yearweek('1989-03-21', 6) """
+ qt_sql """ select yearweek('1989-03-21', 7) """
qt_sql """ select count(*) from (select * from numbers("200")) tmp1 WHERE
0 <= UNIX_TIMESTAMP(); """
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]