-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Week based parsing for ingest date processor #58597
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
Week based parsing for ingest date processor #58597
Conversation
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
|
Pinging @elastic/es-core-infra (:Core/Infra/Core) |
| Function<String, ZonedDateTime> getFunction(String format, ZoneId timezone, Locale locale) { | ||
| return (date) -> DateFormatters.from(DateFormatter.forPattern("iso8601").parse(date), timezone) | ||
| .withZoneSameInstant(timezone); | ||
| // |
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.
unfinished comment?
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.
will remove
| assertThat(DateFormat.fromString("tai64n"), equalTo(DateFormat.Java)); | ||
| assertThat(DateFormat.fromString("prefix-" + randomAlphaOfLengthBetween(1, 10)), equalTo(DateFormat.Java)); | ||
| } | ||
|
|
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.
nit: extra newlines?
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.
will remove
modules/ingest-common/build.gradle
Outdated
|
|
||
| dependencies { | ||
| compileOnly project(':modules:lang-painless') | ||
| compile project(':libs:elasticsearch-core') |
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.
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
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.
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?
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.
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
rjernst
left a comment
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
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
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
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
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
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
…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
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/MMtype ofdates.
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