bp #53050 Related PR: #40695 Problem Summary: pr #40695 introduced the function `from_iso8601_date`, which parses the string to get year、mouth、 day, and sets the date value through the `set_time_unit` function. Since `set_time_unit` lacks some judgment on mouth, it may get an illegal date in the end, which may cause core in debug mode. sql : `select from_iso8601_date('2023-00-01');` ``` F20250709 09:50:14.366984 3587796 vdatetime_value.h:1222] Check failed: date_v2_value_.month_ != 0 *** Check failure stack trace: *** @ 0x559bd7050d96 google::LogMessage::SendToLog() @ 0x559bd704d7e0 google::LogMessage::Flush() @ 0x559bd70515d9 google::LogMessageFatal::~LogMessageFatal() @ 0x559bc725a570 doris::DateV2Value<>::set_time_unit<>() @ 0x559bc7257380 doris::vectorized::FromIso8601DateV2::execute() @ 0x559bc7255a88 doris::vectorized::FunctionOtherTypesToDateType<>::execute_impl() @ 0x559bc09e0781 doris::vectorized::DefaultExecutable::execute_impl() @ 0x559bc423aa20 doris::vectorized::PreparedFunctionImpl::_execute_skipped_constant_deal() @ 0x559bc4234938 doris::vectorized::PreparedFunctionImpl::execute_without_low_cardinality_columns() @ 0x559bc4233f42 doris::vectorized::PreparedFunctionImpl::default_implementation_for_nulls() @ 0x559bc423a773 doris::vectorized::PreparedFunctionImpl::_execute_skipped_constant_deal() @ 0x559bc4234938 doris::vectorized::PreparedFunctionImpl::execute_without_low_cardinality_columns() @ 0x559bc4234a57 doris::vectorized::PreparedFunctionImpl::execute() ``` ### What problem does this PR solve? Issue Number: close #xxx Related PR: #xxx Problem Summary: ### Release note None ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
This commit is contained in:
@ -1771,4 +1771,76 @@ TEST(VTimestampFunctionsTest, year_of_week_test) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(VTimestampFunctionsTest, from_iso8601_date) {
|
||||
std::string func_name = "from_iso8601_date";
|
||||
InputTypeSet input_types = {TypeIndex::String};
|
||||
|
||||
DataSet data_set = {
|
||||
{{std::string("2020-01-01")}, str_to_date_v2("2020-01-01", "%Y-%m-%d")},
|
||||
{{std::string("2020-01-01")}, str_to_date_v2("2020-01-01", "%Y-%m-%d")},
|
||||
{{std::string("-1")}, Null()},
|
||||
{{std::string("2025-07-11")}, str_to_date_v2("2025-07-11", "%Y-%m-%d")},
|
||||
{{std::string("2024-02-29")}, str_to_date_v2("2024-02-29", "%Y-%m-%d")},
|
||||
{{std::string("2025-02-29")}, Null()},
|
||||
{{std::string("2025-13-01")}, Null()},
|
||||
{{std::string("2020-W10")}, str_to_date_v2("2020-03-02", "%Y-%m-%d")},
|
||||
{{std::string("2025-W28")}, str_to_date_v2("2025-07-07", "%Y-%m-%d")},
|
||||
{{std::string("2025-W53")}, str_to_date_v2("2025-12-29", "%Y-%m-%d")},
|
||||
{{std::string("2025-W00")}, Null()},
|
||||
{{std::string("2020-123")}, str_to_date_v2("2020-05-02", "%Y-%m-%d")},
|
||||
{{std::string("2025-192")}, str_to_date_v2("2025-07-11", "%Y-%m-%d")},
|
||||
{{std::string("2024-366")}, str_to_date_v2("2024-12-31", "%Y-%m-%d")},
|
||||
{{std::string("2025-366")}, Null()},
|
||||
{{std::string("2025-000")}, str_to_date_v2("2024-12-31", "%Y-%m-%d")},
|
||||
{{std::string("2025/07/11")}, Null()},
|
||||
{{std::string("25-07-11")}, Null()},
|
||||
{{std::string("2025-7-11")}, Null()},
|
||||
{{std::string("invalid-date")}, Null()},
|
||||
{{std::string("2025-07-11T12:34:56")}, Null()},
|
||||
{{std::string("-1")}, Null()},
|
||||
{{std::string("9999-12-31")}, str_to_date_v2("9999-12-31", "%Y-%m-%d")},
|
||||
{{std::string("10000-01-01")}, Null()},
|
||||
{{std::string("0001-01-01")}, str_to_date_v2("0001-01-01", "%Y-%m-%d")},
|
||||
{{std::string("0000-12-31")}, str_to_date_v2("0000-12-31", "%Y-%m-%d")},
|
||||
{{std::string("-0001-01-01")}, Null()},
|
||||
{{std::string("2025-01-01")}, str_to_date_v2("2025-01-01", "%Y-%m-%d")},
|
||||
{{std::string("2025-12-31")}, str_to_date_v2("2025-12-31", "%Y-%m-%d")},
|
||||
{{std::string("2025-00-01")}, Null()},
|
||||
{{std::string("2025-13-01")}, Null()},
|
||||
{{std::string("2025--01-01")}, Null()},
|
||||
{{std::string("2025-01-31")}, str_to_date_v2("2025-01-31", "%Y-%m-%d")},
|
||||
{{std::string("2025-04-30")}, str_to_date_v2("2025-04-30", "%Y-%m-%d")},
|
||||
{{std::string("2025-02-28")}, str_to_date_v2("2025-02-28", "%Y-%m-%d")},
|
||||
{{std::string("2024-02-29")}, str_to_date_v2("2024-02-29", "%Y-%m-%d")},
|
||||
{{std::string("2025-01-32")}, Null()},
|
||||
{{std::string("2025-04-31")}, Null()},
|
||||
{{std::string("2025-02-29")}, Null()},
|
||||
{{std::string("2025-02-30")}, Null()},
|
||||
{{std::string("2025-01-00")}, Null()},
|
||||
{{std::string("2025-01--01")}, Null()},
|
||||
{{std::string("2000-02-29")}, str_to_date_v2("2000-02-29", "%Y-%m-%d")},
|
||||
{{std::string("2024-02-29")}, str_to_date_v2("2024-02-29", "%Y-%m-%d")},
|
||||
{{std::string("1900-02-29")}, Null()},
|
||||
{{std::string("2100-02-29")}, Null()},
|
||||
{{std::string("2025-02-29")}, Null()},
|
||||
{{std::string("-2025-01-01")}, Null()},
|
||||
{{std::string("2025--07-01")}, Null()},
|
||||
{{std::string("2025-07--01")}, Null()},
|
||||
{{std::string("")}, Null()},
|
||||
{{std::string("2025")}, str_to_date_v2("2025-01-01", "%Y-%m-%d")},
|
||||
{{std::string("2025-07")}, str_to_date_v2("2025-07-01", "%Y-%m-%d")},
|
||||
{{std::string("99999-01-01")}, Null()},
|
||||
{{std::string("2025-123-01")}, Null()},
|
||||
{{std::string("2025-01-123")}, Null()},
|
||||
{{std::string("2025/01/01")}, Null()},
|
||||
{{std::string("2025.01.01")}, Null()},
|
||||
{{std::string("2025-01-01X")}, Null()},
|
||||
{{std::string("2025--01--01")}, Null()},
|
||||
{{std::string("abcd-01-01")}, Null()},
|
||||
{{std::string("2025-ab-01")}, Null()},
|
||||
{{std::string("2025-01-ab")}, Null()},
|
||||
};
|
||||
|
||||
static_cast<void>(check_function<DataTypeDateV2, true>(func_name, input_types, data_set));
|
||||
}
|
||||
} // namespace doris::vectorized
|
||||
|
||||
Reference in New Issue
Block a user