Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marin-ma committed Aug 9, 2023
1 parent 32def27 commit fde1683
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion velox/type/TimestampConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ constexpr int32_t kCumulativeYearDays[] = {

namespace {

// Enum to dictate parsing modes for date strings.
//
// kStrict: For date string conversion, align with DuckDB's implementation.
//
// kNonStrict: For timestamp string conversion, align with DuckDB's
// implementation.
//
// kStandardCast: Strictly processes dates in the [+-](YYYY-MM-DD) format.
// Align with Presto casting conventions.
//
// kNonStandardCast: Like standard but permits missing day/month and allows
// trailing 'T' or spaces. Align with Spark SQL casting conventions.
enum class ParseMode { kStrict, kNonStrict, kStandardCast, kNonStandardCast };

inline bool characterIsSpace(char c) {
Expand Down Expand Up @@ -576,7 +588,10 @@ castFromDateString(const char* str, size_t len, bool isNonStandardCast) {
: ParseMode::kStandardCast;
if (!tryParseDateString(str, len, pos, daysSinceEpoch, mode)) {
VELOX_USER_FAIL(
"Unable to parse date value: \"{}\", expected format is (YYYY-MM-DD)",
"Unable to parse date value: \"{}\"."
"In Spark SQL, valid date string patterns include "
"(YYYY, YYYY-MM, YYYY-MM-DD), and any pattern prefixed with [+-]; "
"while in Presto, the supported pattern is [+-](YYYY-MM-DD).",
std::string(str, len));
}
return daysSinceEpoch;
Expand Down

0 comments on commit fde1683

Please sign in to comment.