Skip to content

Conversation

@ivancea
Copy link
Contributor

@ivancea ivancea commented Oct 17, 2025

Continuation of #136637

Configure tests to work with SET, and add/update tests for:

  • Request "time_zone" parameter
  • "SET" "time_zone" parameter
  • Functions currently affected by Configuration.zoneId

Also, use random configurations by default for unit tests, so we catch and update functions not testing configuration changes.

@ivancea ivancea added >test Issues or PRs that are addressing/adding tests Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.3.0 labels Oct 17, 2025
ivancea and others added 3 commits October 17, 2025 18:12
# 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
Copy link
Contributor Author

@ivancea ivancea Oct 27, 2025

Choose a reason for hiding this comment

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

This depends on the locale, so a random locale would break the tests

Copy link
Contributor Author

@ivancea ivancea Oct 27, 2025

Choose a reason for hiding this comment

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

This depends on the locale, so a random locale would break the tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're testing the configuration "now()", so we reuse it. It could be randomized too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This depends on both the zoneId and the locale

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This depends on both the zoneId and the locale

Copy link
Contributor Author

@ivancea ivancea Oct 27, 2025

Choose a reason for hiding this comment

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

This depends on the locale.
As unary() and sibling functions doesn't accept a custom logic on testcases, I added that "mapTestCase()" at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This depends on the zoneId

assertNotEquals(expr, differentExpr);
}

private static Configuration randomConfiguration() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reusing ConfigurationTestUtils

Comment on lines +39 to +40
if (line.endsWith("\\;")) {
// SET statement with escaped ";"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could use other mechanism; I just chose a typical one here. Listening for opinions

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 we have plenty of queries that end with a ;, so the practical alternatives to this would be

  • change hundreds of tests and move the ; to a new line
  • give up and always have a SET followed by a FROM on the same line.

In conclusion, your solution seems reasonable

@ivancea ivancea marked this pull request as ready for review October 27, 2025 16:47
@elasticsearchmachine
Copy link
Collaborator

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

public Object parse(String line) {
// read the query
if (testCase == null) {
if (line.startsWith(SCHEMA_PREFIX)) {
Copy link
Contributor Author

@ivancea ivancea Oct 28, 2025

Choose a reason for hiding this comment

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

This came from QL; I removed it here. It wasn't being used anywhere

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

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!

You only have one failing test due to randomization, but the problem is not in your PR (the test needs a fix)

public Object parse(String line) {
// read the query
if (testCase == null) {
if (line.startsWith(SCHEMA_PREFIX)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines +39 to +40
if (line.endsWith("\\;")) {
// SET statement with escaped ";"
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 we have plenty of queries that end with a ;, so the practical alternatives to this would be

  • change hundreds of tests and move the ; to a new line
  • give up and always have a SET followed by a FROM on the same line.

In conclusion, your solution seems reasonable

ivancea and others added 3 commits October 28, 2025 15:42
# Conflicts:
#	x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java
@ivancea ivancea enabled auto-merge (squash) October 29, 2025 11:04
@ivancea ivancea merged commit a328b58 into elastic:main Oct 29, 2025
34 checks passed
@ivancea ivancea deleted the esql-time-zone-tests branch October 29, 2025 12:11
chrisparrinello pushed a commit to chrisparrinello/elasticsearch that referenced this pull request Nov 3, 2025
Continuation of elastic#136637

Configure tests to work with SET, and add/update tests for:
- Request "time_zone" parameter
- "SET" "time_zone" parameter
- Functions currently affected by `Configuration.zoneId`

Also, use random configurations by default for unit tests, so we catch and update functions not testing configuration changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) >test Issues or PRs that are addressing/adding tests v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants