-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Use ISODateTimeFormat as default for SIMPLE_DATE_FORMAT #9378
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9378 +/- ##
============================================
- Coverage 69.76% 62.75% -7.02%
+ Complexity 4787 4569 -218
============================================
Files 1885 1878 -7
Lines 100293 100315 +22
Branches 15256 15293 +37
============================================
- Hits 69966 62949 -7017
- Misses 25381 32624 +7243
+ Partials 4946 4742 -204
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Can you put some examples on how to use this in schema? |
Already added it in docs - https://docs.pinot.apache.org/v/release-0.11.0/basics/components/schema#new-datetime-formats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise
@@ -71,7 +74,14 @@ public DateTimeFormatPatternSpec(TimeFormat timeFormat, @Nullable String sdfPatt | |||
_dateTimeZone = DEFAULT_DATE_TIME_ZONE; | |||
} | |||
try { | |||
_dateTimeFormatter = DateTimeFormat.forPattern(_sdfPattern).withZone(_dateTimeZone).withLocale(DEFAULT_LOCALE); | |||
if (_sdfPattern == null) { | |||
LOGGER.warn("SIMPLE_DATE_FORMAT pattern was found to be null. Using ISODateTimeFormat as default"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't log warning here
@@ -56,8 +59,8 @@ public DateTimeFormatPatternSpec(TimeFormat timeFormat) { | |||
public DateTimeFormatPatternSpec(TimeFormat timeFormat, @Nullable String sdfPatternWithTz) { | |||
_timeFormat = timeFormat; | |||
if (timeFormat == TimeFormat.SIMPLE_DATE_FORMAT) { | |||
Preconditions.checkArgument(StringUtils.isNotEmpty(sdfPatternWithTz), "Must provide SIMPLE_DATE_FORMAT pattern"); | |||
Matcher m = SDF_PATTERN_WITH_TIMEZONE.matcher(sdfPatternWithTz); | |||
Matcher m = sdfPatternWithTz != null ? SDF_PATTERN_WITH_TIMEZONE.matcher(sdfPatternWithTz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should skip the regex matching if it does not exist
Matcher m = sdfPatternWithTz != null ? SDF_PATTERN_WITH_TIMEZONE.matcher(sdfPatternWithTz) | |
if (sdfPatternWithTz != null) { | |
... | |
} else { | |
_sdfPattern = null; | |
_dateTimeZone = DEFAULT_DATE_TIME_ZONE; | |
} |
@@ -97,7 +106,14 @@ public DateTimeFormatPatternSpec(TimeFormat timeFormat, @Nullable String sdfPatt | |||
_dateTimeZone = DEFAULT_DATE_TIME_ZONE; | |||
} | |||
try { | |||
_dateTimeFormatter = DateTimeFormat.forPattern(_sdfPattern).withZone(_dateTimeZone).withLocale(DEFAULT_LOCALE); | |||
if (_sdfPattern == null) { | |||
LOGGER.warn("SIMPLE_DATE_FORMAT pattern was found to be null. Using ISODateTimeFormat as default"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't log warning here
0caf86f
to
1c0caeb
Compare
Currently, it is mandatory to specify a pattern if using
SIMPLE_DATE_FORMAT
. However, in order to reduce schema complexity, we can allow users to not specify the patterns and use standard ISO time format to parse the date time.The ISO parser also supports optional. So users can simply use
yyyy
,yyyy-MM
,yyyy-MM-dd
and so on.