Skip to content

Conversation

@pgomulka
Copy link
Contributor

@pgomulka pgomulka commented Jun 26, 2020

Date processor was incorrectly parsing week based dates as when a
weekbased year was provided ingest module was thinking year was not
on a date and was trying to applying the logic for dd/MM type of
dates.
For testing ingest has to have access to ISOCalendarDataProvider in
order to correctly calculate week based dates with ISO rules.
Date Processor is also allowing users to specify locale parameter. It
should be taken into account when parsing dates - currently only used
for formatting. If someone specifies 'en-us' locale, then calendar data
rules for that locale should be used.
The exception is iso8601 format. If someone is using that format,
then locale should not override calendar data rules.
closes #58479

Date processor was incorrectly parsing week based dates as when a
weekbased year was provided ingest module was thinking year was not
on a date and was trying to applying the logic for `dd/MM` type of
dates.
For testing ingest has to have access to ISOCalendarDataProvider in
order to correctly calculate week based dates with ISO rules.
Date Processor is also allowing users to specify locale parameter. It
should be taken into account when parsing dates - currently only used
for formatting. If someone specifies 'en-us' locale, then calendar data
rules for that locale should be used.

closes elastic#58479
@pgomulka pgomulka self-assigned this Jun 26, 2020
@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Jun 26, 2020
@pgomulka pgomulka requested a review from rjernst June 26, 2020 13:09
Function<String, ZonedDateTime> getFunction(String format, ZoneId timezone, Locale locale) {
return (date) -> DateFormatters.from(DateFormatter.forPattern("iso8601").parse(date), timezone)
.withZoneSameInstant(timezone);
//
Copy link
Member

Choose a reason for hiding this comment

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

unfinished comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will remove

assertThat(DateFormat.fromString("tai64n"), equalTo(DateFormat.Java));
assertThat(DateFormat.fromString("prefix-" + randomAlphaOfLengthBetween(1, 10)), equalTo(DateFormat.Java));
}

Copy link
Member

Choose a reason for hiding this comment

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

nit: extra newlines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will remove


dependencies {
compileOnly project(':modules:lang-painless')
compile project(':libs:elasticsearch-core')
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? modules depend on server, implicitly, so we should be able to use the date classes moved there from server, not need them in core lib

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had problem accessing IsoCalendarDataProvider from server when running ingest yml tests.
Maybe adding this as test only? But then again it has to be available when running a cluster for yml test.
Any ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

interesting. I cannot reproduce that failure now. I can see from dependency tree that server is indeed on a test compile classpath. Not sure how was this failing for me before..
Reverted back the change moving IsoCalendarDataProvider

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

@pgomulka pgomulka merged commit ee79ae0 into elastic:master Jul 1, 2020
pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Jul 1, 2020
Date processor was incorrectly parsing week based dates because when a
weekbased year was provided ingest module was thinking year was not
on a date and was trying to applying the logic for dd/MM type of
dates.
Date Processor is also allowing users to specify locale parameter. It
should be taken into account when parsing dates - currently only used
for formatting. If someone specifies 'en-us' locale, then calendar data
rules for that locale should be used.
The exception is iso8601 format. If someone is using that format,
then locale should not override calendar data rules.
closes elastic#58479
# Conflicts:
#	server/src/main/java/org/elasticsearch/common/time/DateFormatters.java
pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Jul 1, 2020
Date processor was incorrectly parsing week based dates because when a
weekbased year was provided ingest module was thinking year was not
on a date and was trying to applying the logic for dd/MM type of
dates.
Date Processor is also allowing users to specify locale parameter. It
should be taken into account when parsing dates - currently only used
for formatting. If someone specifies 'en-us' locale, then calendar data
rules for that locale should be used.
The exception is iso8601 format. If someone is using that format,
then locale should not override calendar data rules.
closes elastic#58479
# Conflicts:
#	server/src/main/java/org/elasticsearch/common/time/DateFormatters.java
pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Jul 1, 2020
Date processor was incorrectly parsing week based dates because when a
weekbased year was provided ingest module was thinking year was not
on a date and was trying to applying the logic for dd/MM type of
dates.
Date Processor is also allowing users to specify locale parameter. It
should be taken into account when parsing dates - currently only used
for formatting. If someone specifies 'en-us' locale, then calendar data
rules for that locale should be used.
The exception is iso8601 format. If someone is using that format,
then locale should not override calendar data rules.
closes elastic#58479
# Conflicts:
#	modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateFormat.java
#	modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/30_date_processor.yml
#	server/src/main/java/org/elasticsearch/common/time/DateFormatters.java
#	server/src/main/java/org/elasticsearch/common/time/IsoCalendarDataProvider.java
#	server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java
#	server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java
pgomulka added a commit that referenced this pull request Jul 1, 2020
Date processor was incorrectly parsing week based dates because when a
weekbased year was provided ingest module was thinking year was not
on a date and was trying to applying the logic for dd/MM type of
dates.
Date Processor is also allowing users to specify locale parameter. It
should be taken into account when parsing dates - currently only used
for formatting. If someone specifies 'en-us' locale, then calendar data
rules for that locale should be used.
The exception is iso8601 format. If someone is using that format,
then locale should not override calendar data rules.
closes #58479
pgomulka added a commit that referenced this pull request Jul 1, 2020
Date processor was incorrectly parsing week based dates because when a
weekbased year was provided ingest module was thinking year was not
on a date and was trying to applying the logic for dd/MM type of
dates.
Date Processor is also allowing users to specify locale parameter. It
should be taken into account when parsing dates - currently only used
for formatting. If someone specifies 'en-us' locale, then calendar data
rules for that locale should be used.
The exception is iso8601 format. If someone is using that format,
then locale should not override calendar data rules.
closes #58479
pgomulka added a commit that referenced this pull request Jul 2, 2020
…58805)

Date processor was incorrectly parsing week based dates because when a
weekbased year was provided ingest module was thinking year field was not
present on a date and was trying to applying the logic for dd/MM type of
dates.
Date Processor is also allowing users to specify locale parameter. It
should be taken into account when parsing dates - currently only used
for formatting. If someone specifies 'en-us' locale, then calendar data
rules for that locale should be used.
The iso8601 ingest format is still using joda implementation
closes #58479
pgomulka added a commit that referenced this pull request May 11, 2021
the bug fixed in 7.12 changed the way the year is defaulted
the bug fix - #65717
the bug was introduced by #58597
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 v7.8.1 v7.9.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date processor incorrectly parses week based dates with java.time

4 participants