Use ISODateTimeFormat as default for SIMPLE_DATE_FORMAT #9378
Merged
KKcorps merged 5 commits intoapache:masterfrom Sep 16, 2022
Merged
Use ISODateTimeFormat as default for SIMPLE_DATE_FORMAT #9378KKcorps merged 5 commits intoapache:masterfrom
KKcorps merged 5 commits intoapache:masterfrom
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 |
Contributor
|
Can you put some examples on how to use this in schema? |
Contributor
Author
|
Already added it in docs - https://docs.pinot.apache.org/v/release-0.11.0/basics/components/schema#new-datetime-formats |
Jackie-Jiang
approved these changes
Sep 14, 2022
| 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"); |
Contributor
There was a problem hiding this comment.
We shouldn't log warning here
| 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) |
Contributor
There was a problem hiding this comment.
We should skip the regex matching if it does not exist
Suggested change
| Matcher m = sdfPatternWithTz != null ? SDF_PATTERN_WITH_TIMEZONE.matcher(sdfPatternWithTz) | |
| if (sdfPatternWithTz != null) { | |
| ... | |
| } else { | |
| _sdfPattern = null; | |
| _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"); |
Contributor
There was a problem hiding this comment.
We shouldn't log warning here
0caf86f to
1c0caeb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-ddand so on.