This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 41be96c98ba branch-4.1: [fix](be) Normalize v1 date string cast result
#64575 (#64744)
41be96c98ba is described below
commit 41be96c98bac29c526875a3fdebf25992c36d280
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Jun 24 10:27:53 2026 +0800
branch-4.1: [fix](be) Normalize v1 date string cast result #64575 (#64744)
Cherry-picked from #64575
Co-authored-by: TengJianPing <[email protected]>
Co-authored-by: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
---
be/src/exprs/function/cast/cast_to_date_or_datetime_impl.hpp | 2 ++
be/test/exprs/function/cast/cast_to_date_test.cpp | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/be/src/exprs/function/cast/cast_to_date_or_datetime_impl.hpp
b/be/src/exprs/function/cast/cast_to_date_or_datetime_impl.hpp
index 931c733e60c..070b9325416 100644
--- a/be/src/exprs/function/cast/cast_to_date_or_datetime_impl.hpp
+++ b/be/src/exprs/function/cast/cast_to_date_or_datetime_impl.hpp
@@ -433,6 +433,7 @@ inline bool
CastToDateOrDatetime::from_string_strict_mode(const StringRef& str,
has_second = true;
if (ptr == end) {
// no fraction or timezone part, just return.
+ cast_to_type<TargetType>(res);
return true;
}
goto FRAC;
@@ -555,6 +556,7 @@ inline bool
CastToDateOrDatetime::from_string_strict_mode(const StringRef& str,
part[0]);
if (ptr == end) {
// no minute part, just return.
+ cast_to_type<TargetType>(res);
return true;
}
if (*ptr == ':') {
diff --git a/be/test/exprs/function/cast/cast_to_date_test.cpp
b/be/test/exprs/function/cast/cast_to_date_test.cpp
index f0af88ac1fd..d88bc66d74e 100644
--- a/be/test/exprs/function/cast/cast_to_date_test.cpp
+++ b/be/test/exprs/function/cast/cast_to_date_test.cpp
@@ -85,6 +85,18 @@ TEST_F(FunctionCastTest,
string_to_date_valid_case_strict_mode) {
check_function_for_cast_strict_mode<DataTypeDateV2>(input_types, data_set);
}
+TEST_F(FunctionCastTest, string_to_datev1_valid_case_strict_mode) {
+ InputTypeSet input_types = {PrimitiveType::TYPE_VARCHAR};
+ DataSet data_set = {
+ // Compact formats
+ {{std::string("20240501 01")}, std::string("2024-05-01")},
+ {{std::string("20230716 1920Z")}, std::string("2023-07-16")},
+ {{std::string("20240501T0000")}, std::string("2024-05-01")},
+ {{std::string("20120102030405")}, std::string("2012-01-02")},
+ };
+ check_function_for_cast_strict_mode<DataTypeDate>(input_types, data_set);
+}
+
TEST_F(FunctionCastTest, string_to_date_invalid_cases_in_strict_mode) {
InputTypeSet input_types = {PrimitiveType::TYPE_VARCHAR};
DataSet data_set = {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]