Skip to content

[BugFix] Deletion task failed when using datetime as a deletion predicate #58933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion be/src/storage/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ bool valid_decimal(const string& value_str, uint32_t precision, uint32_t frac) {
bool valid_datetime(const string& value_str) {
const char* datetime_pattern =
"((?:\\d){4})-((?:\\d){2})-((?:\\d){2})[ ]*"
"(((?:\\d){2}):((?:\\d){2}):((?:\\d){2}))?";
"(((?:\\d){2}):((?:\\d){2}):((?:\\d){2})(\\.(\\d{1,6}))?)?";
boost::regex e(datetime_pattern);
boost::smatch what;

Expand Down
9 changes: 9 additions & 0 deletions be/test/storage/utils_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,13 @@ TEST_F(TestUtils, test_is_tracker_hit_hard_limit) {
ASSERT_TRUE(!is_tracker_hit_hard_limit(tracker.get(), 4));
}

TEST_F(TestUtils, test_valid_datetime) {
ASSERT_TRUE(valid_datetime("2020-01-01 00:00:00"));
ASSERT_TRUE(valid_datetime("2020-01-01 00:00:00.0"));
ASSERT_TRUE(valid_datetime("2020-01-01 00:00:00.01"));
ASSERT_TRUE(valid_datetime("2020-01-01 00:00:00.012345"));
ASSERT_TRUE(valid_datetime("2020-01-01 00:00:00.1230"));
ASSERT_FALSE(valid_datetime("2020-01-01 00:00:00.0123456"));
}

} // namespace starrocks
40 changes: 40 additions & 0 deletions test/sql/test_datetime/R/test_datetime
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,44 @@ select * from test_datetime order by c1;
11 2020-01-01 00:00:00.123400
12 2020-01-01 00:00:00.123450
13 2020-01-01 00:00:00.123450
-- !result
delete from test_datetime where c2 = '2020-01-01 00:00:00';
-- result:
-- !result
delete from test_datetime where c2 = '2020-01-01 00:00:00.0';
-- result:
-- !result
delete from test_datetime where c2 = '2020-01-01 00:00:00.012';
-- result:
-- !result
select * from test_datetime order by c1;
-- result:
3 2020-01-01 00:00:00.010000
5 2020-01-01 00:00:00.012300
6 2020-01-01 00:00:00.012340
7 2020-01-01 00:00:00.012345
8 2020-01-01 00:00:00.100000
9 2020-01-01 00:00:00.120000
10 2020-01-01 00:00:00.123000
11 2020-01-01 00:00:00.123400
12 2020-01-01 00:00:00.123450
13 2020-01-01 00:00:00.123450
-- !result
delete from test_datetime where c2 = '2020-01-01 00:00:00.1';
-- result:
-- !result
delete from test_datetime where c2 = '2020-01-01 00:00:00.123';
-- result:
-- !result
delete from test_datetime where c2 = '2020-01-01 00:00:00.123450';
-- result:
-- !result
select * from test_datetime order by c1;
-- result:
3 2020-01-01 00:00:00.010000
5 2020-01-01 00:00:00.012300
6 2020-01-01 00:00:00.012340
7 2020-01-01 00:00:00.012345
9 2020-01-01 00:00:00.120000
11 2020-01-01 00:00:00.123400
-- !result
12 changes: 12 additions & 0 deletions test/sql/test_datetime/T/test_datetime
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,16 @@ insert into test_datetime values
(12, '2020-01-01 00:00:00.12345'),
(13, '2020-01-01 00:00:00.123450');

select * from test_datetime order by c1;

delete from test_datetime where c2 = '2020-01-01 00:00:00';
delete from test_datetime where c2 = '2020-01-01 00:00:00.0';
delete from test_datetime where c2 = '2020-01-01 00:00:00.012';

select * from test_datetime order by c1;

delete from test_datetime where c2 = '2020-01-01 00:00:00.1';
delete from test_datetime where c2 = '2020-01-01 00:00:00.123';
delete from test_datetime where c2 = '2020-01-01 00:00:00.123450';

select * from test_datetime order by c1;
Loading