Skip to content

Conversation

@ivancea
Copy link
Contributor

@ivancea ivancea commented Oct 31, 2025

Timezone settings (Both the request parameter and the SET setting) are snapshot-only.

Add timezone support to DATE_TRUNC, BUCKET and TBUCKET.

The current timezone is already in the Configuration. This PR:

  • Uses the configuration ZoneId from those functions
  • Adds unit tests for edge cases
    • As BUCKET and TBUCKET depend on DATE_TRUNC, DATE_TRUNC tests are reused
  • Adds CSV tests for common cases

For reviewers

Please take a good look at the expected results of DATE_TRUNC in DateTruncTests, and comment any interesting or edge case you can think of!

ivancea and others added 27 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 labels Oct 31, 2025
@ivancea ivancea added the v9.3.0 label Oct 31, 2025
@elasticsearchmachine
Copy link
Collaborator

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

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 made this class for testing purposes, as working with random configurations "with just a single fixed field" was a bit painful. I'm listening for opinions here!

1 | 1991-01-01T00:00:00.000Z
;

dateTruncTimezonesTimeDuration
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new tests begin here!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All date trunc tests were moved to date_trunc.csv-spec, for organization. There was no change or test removed.
I added a comment where the new tests begin in date_trunc.csv-spec

/**
* Support timezones in DATE_TRUNC and dependent functions.
*/
DATE_TRUNC_TIMEZONE_SUPPORT(Build.current().isSnapshot()),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The time_zone SET setting is snapshot-only, so this has to be too

public class Configuration implements Writeable {

public static final int QUERY_COMPRESS_THRESHOLD_CHARS = KB.toIntBytes(5);
public static final ZoneId DEFAULT_TZ = ZoneOffset.UTC;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no default anymore here. Now the default is in the QuerySettings setting

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) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants