Skip to content
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

Merged
merged 5 commits into from Sep 16, 2022

Conversation

KKcorps
Copy link
Contributor

@KKcorps KKcorps commented Sep 11, 2022

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.

@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2022

Codecov Report

Merging #9378 (1c0caeb) into master (65e97d2) will decrease coverage by 7.01%.
The diff coverage is 82.85%.

@@             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     
Flag Coverage Δ
integration1 26.05% <0.00%> (-0.03%) ⬇️
integration2 24.64% <0.00%> (-0.20%) ⬇️
unittests1 66.99% <82.85%> (+0.03%) ⬆️
unittests2 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ache/pinot/spi/data/DateTimeFormatPatternSpec.java 77.02% <76.92%> (-2.01%) ⬇️
.../org/apache/pinot/spi/data/DateTimeFormatSpec.java 82.92% <100.00%> (+1.10%) ⬆️
...pinot/controller/recommender/io/ConfigManager.java 0.00% <0.00%> (-100.00%) ⬇️
.../org/apache/pinot/client/AggregationResultSet.java 0.00% <0.00%> (-100.00%) ⬇️
...ntroller/recommender/rules/impl/JsonIndexRule.java 0.00% <0.00%> (-100.00%) ⬇️
...troller/recommender/io/metadata/FieldMetadata.java 0.00% <0.00%> (-100.00%) ⬇️
...roller/recommender/rules/impl/BloomFilterRule.java 0.00% <0.00%> (-100.00%) ⬇️
...oller/api/resources/PinotControllerAppConfigs.java 0.00% <0.00%> (-100.00%) ⬇️
...ler/recommender/data/generator/BytesGenerator.java 0.00% <0.00%> (-100.00%) ⬇️
...er/recommender/io/metadata/SchemaWithMetaData.java 0.00% <0.00%> (-100.00%) ⬇️
... and 296 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@xiangfu0
Copy link
Contributor

Can you put some examples on how to use this in schema?

@KKcorps
Copy link
Contributor Author

KKcorps commented Sep 14, 2022

Copy link
Contributor

@Jackie-Jiang Jackie-Jiang left a 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");
Copy link
Contributor

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)
Copy link
Contributor

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

Suggested change
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");
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants