Skip to content

Index name expression resolver bwc layer for date parsing#58503

Merged
pgomulka merged 15 commits intoelastic:6.8from
pgomulka:bp/index_name_expression_resolver
Jul 2, 2020
Merged

Index name expression resolver bwc layer for date parsing#58503
pgomulka merged 15 commits intoelastic:6.8from
pgomulka:bp/index_name_expression_resolver

Conversation

@pgomulka
Copy link
Copy Markdown
Contributor

@pgomulka pgomulka commented Jun 24, 2020

backports #34507

closes #58481
also closes general parsing issue (no date processors) #58602

@pgomulka pgomulka added the :Core/Infra/Core Core issues without another label label Jun 24, 2020
@pgomulka pgomulka self-assigned this Jun 24, 2020
@pgomulka pgomulka requested a review from rjernst June 25, 2020 10:40
@pgomulka pgomulka marked this pull request as ready for review June 25, 2020 10:40
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Core)

@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Jun 25, 2020
Copy link
Copy Markdown
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few questions

expressionResolvers = Arrays.asList(
dateMathExpressionResolver,
new WildcardExpressionResolver());
dateMathExpressionResolver = new DateMathExpressionResolver(settings),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why is this moved here? i think setting a member variable shoudl be done on it's own line, like it was before, not hidden inside a list initialization

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ agree. It was moved because I just cherrypicked the changes from https://github.com/elastic/elasticsearch/pull/34507/files and there was no conflict on this one
will fix

this.defaultDateFormatter = DateTimeFormat.forPattern(defaultDateFormatterPattern);
this.defaultTimeZone = ZoneId.of(defaultTimeZoneId);
defaultDateFormatterPattern = settings.get("date_math_expression_resolver.default_date_format", "uuuu.MM.dd");
this.defaultDateFormatter = DateFormatters.forPattern("uuuu.MM.dd");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this use the pattern in defaultDateFormatterPattern?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, this should use the defaultDateFormatterPattern

defaultDateFormatterPattern = settings.get("date_math_expression_resolver.default_date_format", "YYYY.MM.dd");
this.defaultDateFormatter = DateTimeFormat.forPattern(defaultDateFormatterPattern);
this.defaultTimeZone = ZoneId.of(defaultTimeZoneId);
defaultDateFormatterPattern = settings.get("date_math_expression_resolver.default_date_format", "uuuu.MM.dd");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is in 6.8, shouldn't this default format be prefixed with '8' since we still use joda by default here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, should be with 8. will fix

timeZone = DateTimeZone.forID(patternAndTZid.substring(formatPatternTimeZoneSeparatorIndex + 1));
dateFormatterPattern
= dateFormatterPatternAndTimeZoneId.substring(0, formatPatternTimeZoneSeparatorIndex);
timeZone = ZoneId.of(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We previously added the '8' prefix in date formats so that both joda and java formats could be distinguished. I have a vague memory that the zone identifiers do not completely match up between joda and java. Is this correct? If so, what happens if the format specified by the user is one not supported by java?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we test against this discrepancies in https://github.com/elastic/elasticsearch/blob/6.8/server/src/test/java/org/elasticsearch/common/time/DateUtilsTests.java#L38
as long as timezone dbs are the same in both joda and java (and we make sure about this with this test) then there should always be a match

@pgomulka pgomulka requested a review from rjernst July 2, 2020 19:56
Copy link
Copy Markdown
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team v6.8.11

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants