ESQL: DateDiff timezone support#138316
Merged
ivancea merged 85 commits intoelastic:mainfrom Nov 25, 2025
Merged
Conversation
… ones that use it
# Conflicts: # x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatTests.java
# Conflicts: # x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java
# Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/grouping/TBucket.java
Collaborator
|
Hi @ivancea, I've created a changelog YAML for you. |
Collaborator
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
luigidellaquila
approved these changes
Nov 24, 2025
| public class DateDiff extends EsqlConfigurationFunction { | ||
| public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "DateDiff", DateDiff::new); | ||
|
|
||
| public static final ZoneId UTC = org.elasticsearch.xpack.esql.core.util.DateUtils.UTC; |
Contributor
There was a problem hiding this comment.
I think this is not used anymore
| protected Expression build(Source source, List<Expression> args) { | ||
| return new DateDiff(source, args.get(0), args.get(1), args.get(2)); | ||
| protected Expression buildWithConfiguration(Source source, List<Expression> args, Configuration configuration) { | ||
| return new DateDiff(source, args.get(0), args.get(1), args.get(2), configuration); // TODO: Add config here |
Contributor
There was a problem hiding this comment.
I guess the TODO is a leftover
ncordon
pushed a commit
to ncordon/elasticsearch
that referenced
this pull request
Nov 26, 2025
DateDiff does 2 things, depending on if the unit is smaller than a day or not: - For less than a day (time), it works the same independently of the timezone - For days and bigger intervals, the actual day numberss are checked, leading to potential differencies if, for example, a DST changes the day number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DateDiff does 2 things, depending on if the unit is smaller than a day or not: