Skip to content

ESQL: Add timezone to add and sub operators, and ConfigurationAware planning support#140101

Merged
ivancea merged 16 commits intoelastic:mainfrom
ivancea:esql-operators-timezone
Jan 9, 2026
Merged

ESQL: Add timezone to add and sub operators, and ConfigurationAware planning support#140101
ivancea merged 16 commits intoelastic:mainfrom
ivancea:esql-operators-timezone

Conversation

@ivancea
Copy link
Contributor

@ivancea ivancea commented Dec 31, 2025

Add timezone support to Add (+) and Sub (-) operators (Snapshot-only, as setting a timezone is snapshot-only too).

Because those nodes are created in the parser, before the configuration is available, this PR also uses the ConfigurationAware interface, and completes its implementation by adding an Analyzer rule that replaces the "marker" configuration with the real one.
Also, some validations were added in the Verifiers to ensure we don't end up with the marker configuration in any productive place.

The list of changes:

  • ConfigurationAware handling in Analyzer and Verifiers
  • Added the Configuration to Add and Sub (+ their base class, + tests)
    • This required adding the configuration to many usages of Add and Sub in unrelated tests

@ivancea ivancea added >feature Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.4.0 labels Dec 31, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

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


private static Function<Object, Object> toDateTime(Converter conversion) {
return l -> DateUtils.asDateTime(((Number) conversion.convert(l)).longValue());
return l -> DateUtils.asDateTime(((Number) conversion.convert(l)).longValue(), ZoneOffset.UTC);
Copy link
Contributor Author

@ivancea ivancea Dec 31, 2025

Choose a reason for hiding this comment

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

This is just moving the UTC from inside to the caller.
Converters are being migrated in another PR, which may reuse the ConfigurationAware implementation when merged

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, thanks @ivancea!


private static Expression resolveConfigurationAware(Expression expression, Configuration configuration) {
if (expression instanceof ConfigurationAware ca && ca.configuration() == ConfigurationAware.CONFIGURATION_MARKER) {
return ca.withConfiguration(configuration);
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this solution, it's simple enough and effective 👍

// quick verification for unresolved attributes
checkUnresolvedAttributes(plan, failures);

ConfigurationAware.verifyNoMarkerConfiguration(plan, failures);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@luigidellaquila
Copy link
Contributor

(Snapshot-only, as setting a timezone is snapshot-only too)

Are we tracking all the changes we need to perform before we can un-snapshot SET timezone ?
I we have this old issue #107560, but it doesn't seem to be up to date

@ivancea ivancea merged commit 327892c into elastic:main Jan 9, 2026
35 checks passed
@ivancea ivancea deleted the esql-operators-timezone branch January 9, 2026 13:23
szybia added a commit to szybia/elasticsearch that referenced this pull request Jan 9, 2026
* upstream/main: (76 commits)
  [Inference API] Get _services skips EIS authorization call if CCM is not configured (elastic#139964)
  Improve TSDB codec benchmarks with full encoder and compression metrics (elastic#140299)
  ESQL: Consolidate test `BlockLoaderContext`s (elastic#140403)
  ESQL: Improve Lookup Join performance with CachedDirectoryReader (elastic#139314)
  ES|QL: Add more examples for the match operator (elastic#139815)
  ESQL: Add timezone to add and sub operators, and ConfigurationAware planning support (elastic#140101)
  ESQL: Updated ToIp tests and generated documentation for map parameters (elastic#139994)
  Disable _delete_by_query and _update_by_query for CCS/stateful (elastic#140301)
  Remove unused method ElasticInferenceService.translateToChunkedResults (elastic#140442)
  logging hot threads on large queue of the management threadpool (elastic#140251)
  Search functions docs cleanup (elastic#140435)
  Unmute 350_point_in_time/point-in-time with index filter (elastic#140443)
  Remove unused methods (elastic#140222)
  Add CPS and `project_routing` support for `_mvt` (elastic#140053)
  Streamline `ShardDeleteResults` collection (elastic#140363)
  Fix Docker build to use --load for single-platform images (elastic#140402)
  Parametrize + test VectorScorerOSQBenchmark (elastic#140354)
  `RecyclerBytesStreamOutput` using absolute offsets (elastic#140303)
  Define bulk float native methods for vector scoring (elastic#139885)
  Make `TimeSeriesAggregate` `TimestampAware` (elastic#140270)
  ...
jimczi pushed a commit to jimczi/elasticsearch that referenced this pull request Jan 12, 2026
…lanning support (elastic#140101)

Add timezone support to `Add` (+) and `Sub` (-) operators (Snapshot-only, as setting a timezone is snapshot-only too).

Because those nodes are created in the parser, before the configuration is available, this PR also uses the `ConfigurationAware` interface, and completes its implementation by adding an `Analyzer` rule that replaces the "marker" configuration with the real one.
Also, some validations were added in the `Verifiers` to ensure we don't end up with the marker configuration in any productive place.

The list of changes:
- ConfigurationAware handling in Analyzer and Verifiers
- Added the Configuration to Add and Sub (+ their base class, + tests)
  - This required adding the configuration to many usages of Add and Sub in unrelated tests
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.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants