-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Core: Don't rely on java time for epoch seconds formatting #34086
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
Core: Don't rely on java time for epoch seconds formatting #34086
Conversation
In order to be compatible with joda time, this adds an epoch seconds formatter, that is able to parse floating point values. However joda time discards the floating point values, but still parses the data, where as this one is able to parse the whole value including milliseconds. This also allows to name the formatter 'epoch_seconds' with an s at the end just like 'epoch_millis'.
Pinging @elastic/es-core-infra |
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, I left a few suggestions
@@ -1374,7 +1373,7 @@ public static DateFormatter forPattern(String input, Locale locale) { | |||
return YEAR_MONTH; | |||
} else if ("yearMonthDay".equals(input) || "year_month_day".equals(input)) { | |||
return YEAR_MONTH_DAY; | |||
} else if ("epoch_second".equals(input)) { | |||
} else if ("epoch_second".equals(input) || "epoch_seconds".equals(input)) { |
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.
If we are going to add the plural (+1), then we should add a deprecation warning for the non-plural.
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.
ok, this requires some more changes in other tests, I will add this in a follow up PR, but do not want to clutter within this PR, just sticking with epoch_second for now
server/src/main/java/org/elasticsearch/common/time/DateFormatters.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/common/time/EpochSecondsDateFormatter.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public DateFormatter withZone(ZoneId zoneId) { | ||
return this; |
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.
This seems trappy...we should at least have a comment why this is ok, but it seems like we could drop timezones?
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.
the java-time branch will create new objects with a timezone for all the date formatters (same needs to be done for the locale). I will create a separate PR for that after this one.
server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java
Outdated
Show resolved
Hide resolved
…R to not clutter it, requires more test fixes
In order to be compatible with joda time, this adds an epoch seconds formatter, that is able to parse floating point values. However joda time discards the floating point values, but still parses the data, where as this one is able to parse the whole value including milliseconds.
* master: Use more precise does S3 bucket exist method (elastic#34123) LLREST: Introduce a strict mode (elastic#33708) [CCR] Adjust list retryable errors (elastic#33985) Fix AggregationFactories.Builder equality and hash regarding order (elastic#34005) MINOR: Remove some deadcode in NodeEnv and Related (elastic#34133) Rest-Api-Spec: Correct spelling in filter_path description (elastic#33154) Core: Don't rely on java time for epoch seconds formatting (elastic#34086) Retry errors when fetching follower global checkpoint. (elastic#34019) Watcher: Reenable watcher stats REST tests (elastic#34107) Remove special-casing of Synonym filters in AnalysisRegistry (elastic#34034) Rename CCR APIs (elastic#34027) Fixed CCR stats api serialization issues and (elastic#33983) Support 'string'-style queries on metadata fields when reasonable. (elastic#34089) Logging: Drop Settings from security logger get calls (elastic#33940) SQL: Internal refactoring of operators as functions (elastic#34097)
In order to be compatible with joda time, this adds an epoch seconds formatter, that is able to parse floating point values. However joda time discards the floating point values, but still parses the data, where as this one is able to parse the whole value including milliseconds.
In order to be compatible with joda time, this adds an epoch seconds
formatter, that is able to parse floating point values.
However joda time discards the floating point values, but still parses
the data, where as this one is able to parse the whole value including
milliseconds.
This also allows to name the formatter 'epoch_seconds' with an s at the
end just like 'epoch_millis'.