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 e353be7dcb [Bug](date function) Return null if date format is invalid (#11720) e353be7dcb is described below commit e353be7dcbb4ef47329e052251ae5d4f6f37d11a Author: Gabriel <gabrielleeb...@gmail.com> AuthorDate: Fri Aug 12 14:07:55 2022 +0800 [Bug](date function) Return null if date format is invalid (#11720) --- be/src/vec/runtime/vdatetime_value.cpp | 5 ++++- .../query/sql_functions/datetime_functions/test_date_function.out | 3 +++ .../query/sql_functions/datetime_functions/test_date_function.groovy | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/be/src/vec/runtime/vdatetime_value.cpp b/be/src/vec/runtime/vdatetime_value.cpp index 3a4393a706..315851c454 100644 --- a/be/src/vec/runtime/vdatetime_value.cpp +++ b/be/src/vec/runtime/vdatetime_value.cpp @@ -1014,7 +1014,10 @@ static bool str_to_int64(const char* ptr, const char** endptr, int64_t* ret) { n_end = end; } uint64_t value_1 = 0; - while (ptr < n_end && isdigit(*ptr)) { + while (ptr < n_end) { + if (!isdigit(*ptr)) { + return false; + } value_1 *= 10; value_1 += *ptr++ - '0'; } diff --git a/regression-test/data/query/sql_functions/datetime_functions/test_date_function.out b/regression-test/data/query/sql_functions/datetime_functions/test_date_function.out index 1e5c5af5f3..ee492a41b2 100644 --- a/regression-test/data/query/sql_functions/datetime_functions/test_date_function.out +++ b/regression-test/data/query/sql_functions/datetime_functions/test_date_function.out @@ -350,3 +350,6 @@ true -- !sql -- 2022 31 4 +-- !sql -- +\N + diff --git a/regression-test/suites/query/sql_functions/datetime_functions/test_date_function.groovy b/regression-test/suites/query/sql_functions/datetime_functions/test_date_function.groovy index e4a14992d9..6f915f44a1 100644 --- a/regression-test/suites/query/sql_functions/datetime_functions/test_date_function.groovy +++ b/regression-test/suites/query/sql_functions/datetime_functions/test_date_function.groovy @@ -292,4 +292,5 @@ suite("test_date_function", "query") { sql """ drop table ${tableName} """ qt_sql """ select date_format('2022-08-04', '%X %V %w'); """ + qt_sql """ select STR_TO_DATE('Tue Jul 12 20:00:45 CST 2022', '%a %b %e %H:%i:%s %Y'); """ } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org