Skip to content

Commit

Permalink
fix parseDateTimeBestEffortOrNull with empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
ucasfl committed Oct 30, 2020
1 parent 19794be commit f428675
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/IO/parseDateTimeBestEffort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ ReturnType parseDateTimeBestEffortImpl(
}
}

/// If neigher Date nor Time is parsed successfully, it should fail
if (!year && !month && !day_of_month && !has_time)
return on_error("Cannot read DateTime: neither Date nor Time was parsed successfully", ErrorCodes::CANNOT_PARSE_DATETIME);

if (!year)
year = 2000;
if (!month)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
2010-01-01 00:00:00
2010-01-01 01:01:01
2000-01-01 01:01:01
\N
\N
\N
\N
\N
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT parseDateTimeBestEffortOrNull('2010-01-01');
SELECT parseDateTimeBestEffortOrNull('2010-01-01 01:01:01');
SELECT parseDateTimeBestEffortOrNull('01:01:01');
SELECT parseDateTimeBestEffortOrNull('20100');
SELECT parseDateTimeBestEffortOrNull('0100:0100:0000');
SELECT parseDateTimeBestEffortOrNull('x');
SELECT parseDateTimeBestEffortOrNull('');
SELECT parseDateTimeBestEffortOrNull(' ');

0 comments on commit f428675

Please sign in to comment.