-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: Timezone support in DATE_TRUNC, BUCKET and TBUCKET #137450
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
Draft
ivancea
wants to merge
34
commits into
elastic:main
Choose a base branch
from
ivancea:esql-datetrunc-timezone
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
f95c2a8
Add capability and YAML tests for request and SET time_zone parameters
ivancea 569d9e5
Add SET CSV tests, and adapted CsvTests to work with SET statements
ivancea cc15c9f
Escape ; in csv tests with backslash
ivancea 449abe6
Randomize configuration in function tests, and make it static for the…
ivancea 5dec7c3
[CI] Auto commit changes from spotless
fedbf4f
Merge branch 'main' into esql-time-zone-tests
ivancea b088abf
Moved custom config cases to another method
ivancea ee1316c
Add comment on function with config dserialization randomization
ivancea 13d8b4b
Fix multi cluster tests to accept SET statements
ivancea d794329
Merge branch 'main' into esql-time-zone-tests
ivancea 2713280
Fix configuration and source matching in random tests
ivancea f76f5ec
Added function tests for timezones
ivancea 9005c78
Fix typo
ivancea fad189f
Fixed capability requirement
ivancea 4f62f23
Fix ScalbTests
ivancea 4c5adc0
[CI] Auto commit changes from spotless
3f233bf
Add configuration to DATE_TRUNC and related functions
ivancea d81729b
Merge branch 'main' into esql-time-zone-tests
ivancea 8b8a115
Merge branch 'esql-time-zone-tests' into esql-datetrunc-timezone
ivancea a11d4b8
Merge branch 'main' into esql-datetrunc-timezone
ivancea ebd00dd
Added a ConfigurationFUnction interface and fixed tests with static c…
ivancea de30da7
WIP: Initial DateTrunc unit tests
ivancea dcce704
Reuse DateTrunc tests in Bucket and TBucket
ivancea 24e99c1
Added unit tests for timezones
ivancea dd523d5
Extracted matchers
ivancea ad32a98
Moved matchers to a common place
ivancea 539b7a7
Extracted date_trunc csv tests to date
ivancea 5053983
Update docs/changelog/137450.yaml
ivancea a75301c
Fix benchmark
ivancea 7e5c01d
Added CSV tests for timezones on affected functions
ivancea 544c4cf
Fixed Rounding builders being reused
ivancea e499df4
Use DateTrunc zoneId instead of configuration in rule
ivancea 205a15c
Undo roundings test
ivancea 46debec
Fix tests
ivancea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 137450 | ||
| summary: "Timezone support in DATE_TRUNC, BUCKET and TBUCKET" | ||
| area: ES|QL | ||
| type: feature | ||
| issues: [] |
151 changes: 151 additions & 0 deletions
151
...esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/ConfigurationBuilder.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.esql; | ||
|
|
||
| import org.elasticsearch.xpack.esql.plugin.QueryPragmas; | ||
| import org.elasticsearch.xpack.esql.session.Configuration; | ||
|
|
||
| import java.time.ZoneId; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Builder to modify configurations on tests. | ||
| * <p> | ||
| * The {@link Configuration#now()} field is actually modified, so built configurations will also differ there. | ||
| * </p> | ||
| */ | ||
| public class ConfigurationBuilder { | ||
|
|
||
| private String clusterName; | ||
| private String username; | ||
| private ZoneId zoneId; | ||
|
|
||
| private QueryPragmas pragmas; | ||
|
|
||
| private int resultTruncationMaxSizeRegular; | ||
| private int resultTruncationDefaultSizeRegular; | ||
| private int resultTruncationMaxSizeTimeseries; | ||
| private int resultTruncationDefaultSizeTimeseries; | ||
|
|
||
| private Locale locale; | ||
|
|
||
| private String query; | ||
|
|
||
| private boolean profile; | ||
| private boolean allowPartialResults; | ||
|
|
||
| private Map<String, Map<String, Column>> tables; | ||
| private long queryStartTimeNanos; | ||
|
|
||
| public ConfigurationBuilder(Configuration configuration) { | ||
| clusterName = configuration.clusterName(); | ||
| username = configuration.username(); | ||
| zoneId = configuration.zoneId(); | ||
| pragmas = configuration.pragmas(); | ||
| resultTruncationMaxSizeRegular = configuration.resultTruncationMaxSize(false); | ||
| resultTruncationDefaultSizeRegular = configuration.resultTruncationDefaultSize(false); | ||
| resultTruncationMaxSizeTimeseries = configuration.resultTruncationMaxSize(true); | ||
| resultTruncationDefaultSizeTimeseries = configuration.resultTruncationDefaultSize(true); | ||
| locale = configuration.locale(); | ||
| query = configuration.query(); | ||
| profile = configuration.profile(); | ||
| allowPartialResults = configuration.allowPartialResults(); | ||
| tables = configuration.tables(); | ||
| queryStartTimeNanos = configuration.queryStartTimeNanos(); | ||
| } | ||
|
|
||
| public ConfigurationBuilder clusterName(String clusterName) { | ||
| this.clusterName = clusterName; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder username(String username) { | ||
| this.username = username; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder zoneId(ZoneId zoneId) { | ||
| this.zoneId = zoneId; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder pragmas(QueryPragmas pragmas) { | ||
| this.pragmas = pragmas; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder resultTruncationMaxSizeRegular(int resultTruncationMaxSizeRegular) { | ||
| this.resultTruncationMaxSizeRegular = resultTruncationMaxSizeRegular; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder resultTruncationDefaultSizeRegular(int resultTruncationDefaultSizeRegular) { | ||
| this.resultTruncationDefaultSizeRegular = resultTruncationDefaultSizeRegular; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder resultTruncationMaxSizeTimeseries(int resultTruncationMaxSizeTimeseries) { | ||
| this.resultTruncationMaxSizeTimeseries = resultTruncationMaxSizeTimeseries; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder resultTruncationDefaultSizeTimeseries(int resultTruncationDefaultSizeTimeseries) { | ||
| this.resultTruncationDefaultSizeTimeseries = resultTruncationDefaultSizeTimeseries; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder locale(Locale locale) { | ||
| this.locale = locale; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder query(String query) { | ||
| this.query = query; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder profile(boolean profile) { | ||
| this.profile = profile; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder allowPartialResults(boolean allowPartialResults) { | ||
| this.allowPartialResults = allowPartialResults; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder tables(Map<String, Map<String, Column>> tables) { | ||
| this.tables = tables; | ||
| return this; | ||
| } | ||
|
|
||
| public ConfigurationBuilder queryStartTimeNanos(long queryStartTimeNanos) { | ||
| this.queryStartTimeNanos = queryStartTimeNanos; | ||
| return this; | ||
| } | ||
|
|
||
| public Configuration build() { | ||
| return new Configuration( | ||
| zoneId, | ||
| locale, | ||
| username, | ||
| clusterName, | ||
| pragmas, | ||
| resultTruncationMaxSizeRegular, | ||
| resultTruncationDefaultSizeRegular, | ||
| query, | ||
| profile, | ||
| tables, | ||
| queryStartTimeNanos, | ||
| allowPartialResults, | ||
| resultTruncationMaxSizeTimeseries, | ||
| resultTruncationDefaultSizeTimeseries | ||
| ); | ||
| } | ||
| } |
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
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
Oops, something went wrong.
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.
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.
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!