Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zclllyybb committed Oct 16, 2023
1 parent 549e5ee commit ec430d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
17 changes: 13 additions & 4 deletions be/src/vec/runtime/vdatetime_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2306,13 +2306,22 @@ bool DateV2Value<T>::from_date_format_str(const char* format, int format_len, co
tmp++;
}

if (!str_to_int64(val, &tmp, &int_value)) {
return false;
if (tmp - val > 6) {
const char* tmp2 = val + 6;
if (!str_to_int64(val, &tmp2, &int_value)) {
return false;
}
} else {
if (!str_to_int64(val, &tmp, &int_value)) {
return false;
}
}
if constexpr (is_datetime) {
microsecond = int_value * int_exp10(6 - min(6, tmp - val));
frac_part_used = true;
}
microsecond = int_value * int_exp10(6 - min(6, val_end - val));
val = tmp;
time_part_used = true;
frac_part_used = true;
break;
// AM/PM
case 'p':
Expand Down
2 changes: 0 additions & 2 deletions gensrc/script/doris_builtins_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,8 +1104,6 @@

[['str_to_date'], 'DATETIMEV2', ['VARCHAR', 'VARCHAR'], 'ALWAYS_NULLABLE'],
[['str_to_date'], 'DATETIMEV2', ['STRING', 'STRING'], 'ALWAYS_NULLABLE'],
[['str_to_date'], 'DATEV2', ['VARCHAR', 'VARCHAR'], 'ALWAYS_NULLABLE'],
[['str_to_date'], 'DATEV2', ['STRING', 'STRING'], 'ALWAYS_NULLABLE'],
[['date_format'], 'VARCHAR', ['DATETIMEV2', 'VARCHAR'], 'ALWAYS_NULLABLE'],
[['date_format'], 'VARCHAR', ['DATEV2', 'VARCHAR'], 'ALWAYS_NULLABLE'],
[['date', 'to_date', 'datev2', 'to_datev2'], 'DATEV2', ['DATETIMEV2'], 'ALWAYS_NULLABLE'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ February
2014-12-21T12:34:56

-- !sql --
2014-12-21T12:34:56.000789
2014-12-21T12:34:56.789

-- !sql --
2023-07-05T02:09:55.088
2023-07-05T02:09:55.880

-- !sql --
2004-10-18
Expand Down

0 comments on commit ec430d7

Please sign in to comment.