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 e1b878fe10 [Improvement](datev2) apply time LUT to datev2/datetimev2
(#11401)
e1b878fe10 is described below
commit e1b878fe1081784b4d166d1af9796a39ded18fb6
Author: Gabriel <[email protected]>
AuthorDate: Wed Aug 3 17:15:09 2022 +0800
[Improvement](datev2) apply time LUT to datev2/datetimev2 (#11401)
* [Improvement](datev2) apply time LUT to datev2/datetimev2
---
be/src/vec/runtime/vdatetime_value.cpp | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/be/src/vec/runtime/vdatetime_value.cpp
b/be/src/vec/runtime/vdatetime_value.cpp
index 492ee4e391..05a568f9ad 100644
--- a/be/src/vec/runtime/vdatetime_value.cpp
+++ b/be/src/vec/runtime/vdatetime_value.cpp
@@ -2328,6 +2328,10 @@ uint8_t DateV2Value<T>::week(uint8_t mode) const {
template <typename T>
uint32_t DateV2Value<T>::year_week(uint8_t mode) const {
+ if (config::enable_time_lut && mode == 4 && this->year() >= 1950 &&
this->year() < 2030) {
+ return doris::TimeLUT::GetImplement()
+ ->year_week_table[this->year() - 1950][this->month() -
1][this->day() - 1];
+ }
uint16_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 =
@@ -2806,7 +2810,7 @@ bool DateV2Value<T>::to_format_string(const char* format,
int len, char* to) con
// Year for the week where Sunday is the first day of the week,
// numeric, four digits; used with %V
uint16_t year = 0;
- calc_week(this->daynr(), this->year(), this->month(), this->day(),
mysql_week_mode(3),
+ calc_week(this->daynr(), this->year(), this->month(), this->day(),
mysql_week_mode(2),
&year);
pos = int_to_str(year, buf);
to = append_with_prefix(buf, pos - buf, '0', 4, to);
@@ -2939,6 +2943,15 @@ template <typename T>
uint8_t DateV2Value<T>::calc_week(const uint32_t& day_nr, const uint16_t& year,
const uint8_t& month, const uint8_t& day,
uint8_t mode,
uint16_t* to_year) {
+ if (config::enable_time_lut && mode == 3 && year >= 1950 && year < 2030) {
+ return doris::TimeLUT::GetImplement()
+ ->week_of_year_table[year - doris::LUT_START_YEAR][month -
1][day - 1];
+ }
+ // mode=4 is used for week()
+ if (config::enable_time_lut && mode == 4 && year >= 1950 && year < 2030) {
+ return doris::TimeLUT::GetImplement()
+ ->week_table[year - doris::LUT_START_YEAR][month - 1][day - 1];
+ }
bool monday_first = mode & WEEK_MONDAY_FIRST;
bool week_year = mode & WEEK_YEAR;
bool first_weekday = mode & WEEK_FIRST_WEEKDAY;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]