This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/dev-1.1.2 by this push:
new e5dad717f5 [fix](date function) Fix bug for date format %T (#11729)
(#11777)
e5dad717f5 is described below
commit e5dad717f5c96e62157aef43b5de938542de175a
Author: Gabriel <[email protected]>
AuthorDate: Mon Aug 15 13:28:17 2022 +0800
[fix](date function) Fix bug for date format %T (#11729) (#11777)
---
be/src/vec/runtime/vdatetime_value.cpp | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/be/src/vec/runtime/vdatetime_value.cpp
b/be/src/vec/runtime/vdatetime_value.cpp
index 60df6e4205..4b5b00d3f1 100644
--- a/be/src/vec/runtime/vdatetime_value.cpp
+++ b/be/src/vec/runtime/vdatetime_value.cpp
@@ -57,7 +57,11 @@ RE2
VecDateTimeValue::time_zone_offset_format_reg("^[+-]{1}\\d{2}\\:\\d{2}$");
bool VecDateTimeValue::check_range(uint32_t year, uint32_t month, uint32_t
day, uint32_t hour,
uint32_t minute, uint32_t second, uint16_t type) {
bool time = hour > (type == TIME_TIME ? TIME_MAX_HOUR : 23) || minute > 59
|| second > 59;
- return time || check_date(year, month, day);
+ if (type == TIME_TIME) {
+ return time;
+ } else {
+ return time || check_date(year, month, day);
+ }
}
bool VecDateTimeValue::check_date(uint32_t year, uint32_t month, uint32_t day)
{
@@ -1286,22 +1290,32 @@ bool VecDateTimeValue::from_date_format_str(const char*
format, int format_len,
val = tmp;
date_part_used = true;
break;
- case 'r':
- if (!from_date_format_str("%I:%i:%S %p", 11, val, val_end -
val, &tmp)) {
+ case 'r': {
+ VecDateTimeValue tmp_val;
+ if (!tmp_val.from_date_format_str("%I:%i:%S %p", 11, val,
val_end - val, &tmp)) {
return false;
}
+ this->_hour = tmp_val._hour;
+ this->_minute = tmp_val._minute;
+ this->_second = tmp_val._second;
val = tmp;
time_part_used = true;
- already_set_time_part = true;
+ already_set_time_part = true;
break;
- case 'T':
- if (!from_date_format_str("%H:%i:%S", 8, val, val_end - val,
&tmp)) {
+ }
+ case 'T': {
+ VecDateTimeValue tmp_val;
+ if (!tmp_val.from_date_format_str("%H:%i:%S", 8, val, val_end
- val, &tmp)) {
return false;
}
+ this->_hour = tmp_val._hour;
+ this->_minute = tmp_val._minute;
+ this->_second = tmp_val._second;
time_part_used = true;
- already_set_time_part = true;
+ already_set_time_part = true;
val = tmp;
break;
+ }
case '.':
while (val < val_end && ispunct(*val)) {
val++;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]