Skip to content

ESQL: DateDiff timezone support#138316

Merged
ivancea merged 85 commits intoelastic:mainfrom
ivancea:esql-add-timezone-date-functions
Nov 25, 2025
Merged

ESQL: DateDiff timezone support#138316
ivancea merged 85 commits intoelastic:mainfrom
ivancea:esql-add-timezone-date-functions

Conversation

@ivancea
Copy link
Contributor

@ivancea ivancea commented Nov 19, 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
ivancea and others added 30 commits October 17, 2025 12:51
# 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
@ivancea ivancea added >feature Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.3.0 labels Nov 19, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @ivancea, I've created a changelog YAML for you.

@ivancea ivancea marked this pull request as ready for review November 19, 2025 18:57
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

Copy link
Contributor

@luigidellaquila luigidellaquila left a comment

Choose a reason for hiding this comment

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

LGTM

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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

I guess the TODO is a leftover

@ivancea ivancea added the test-release Trigger CI checks against release build label Nov 25, 2025
@ivancea ivancea enabled auto-merge (squash) November 25, 2025 15:09
@ivancea ivancea merged commit 719332e into elastic:main Nov 25, 2025
34 checks passed
@ivancea ivancea deleted the esql-add-timezone-date-functions branch November 25, 2025 16:12
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >feature Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) test-release Trigger CI checks against release build v9.3.0

3 participants