diff --git a/be/src/vec/runtime/vdatetime_value.cpp b/be/src/vec/runtime/vdatetime_value.cpp index 2a7cbe737cb9ea..5ac700d111050e 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 1d6f5de32323de..b6c261cb034f53 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 baf8d83ac81366..7b2894c3f601e5 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(); """