Skip to content

Conversation

luigidellaquila
Copy link
Contributor

@luigidellaquila luigidellaquila commented Jul 2, 2025

To avoid collisions with subquery syntax, we disallow the usage of ( and ) in unquoted index patterns and enrich policy names.

Fixes: #130378

@luigidellaquila luigidellaquila added >bug :Analytics/ES|QL AKA ESQL v9.0.0 auto-backport Automatically create backport pull requests when merged labels Jul 3, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@luigidellaquila luigidellaquila marked this pull request as ready for review July 4, 2025 09:30
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jul 4, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@idegtiarenko
Copy link
Contributor

I believe we keep enrich policy definition in cluster state. Should we prohibit creation of new ones with brackets? What should we do with ones previously created with brackets in names? Please let me know if this concerns are separate from this change

@luigidellaquila
Copy link
Contributor Author

luigidellaquila commented Jul 7, 2025

Should we prohibit creation of new ones with brackets?

Enrich policies allow brackets, so I don't think we can just prohibit it.
With this change, we can allow brackets also in policy names, as long as they are quoted.

Yaml tests apparently have problems creating policies with brackets, but I'll add a Java integration test for it.

@@ -0,0 +1,102 @@
---
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 has to be a separate file and with a single test, just because the policy delete doesn't seem to work with brackets

  - do:
      enrich.delete_policy:
        name: <name with brackets here>

Apparently the bracket collides with some regex evaluation that happens during the process.
I couldn't find a way to work around this problem, but it seems unrelated to ES|QL, so I guess we can handle it separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No way, I had to skip the test.
If I don't delete the enrich policy, it will make other tests fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@luigidellaquila
Copy link
Contributor Author

@idegtiarenko I added a test that uses an enrich policy with brackets (with quotes), and it works as expected.

can't delete enrich policy
Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

Looks good, but you need to be paranoid with grammar changes and add more tests. I've put in some examples which should be extended to other commands that use index names patterns.

@@ -0,0 +1,5 @@
pr: 130427
summary: Disallow brackets in unquoted index pattersn
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo

UnresolvedRelation right = as(lookup.right(), UnresolvedRelation.class);
assertThat(right.indexPattern().indexPattern(), is("foo)"));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Please, add more unit tests here. The above ones are the bare minimum imo, but it's always good to be paranoid with grammar changes as the devil is in the edge cases :-)).

from te()st
from \"te()st\"
from concat(foo, bar)
from ((((()))))
from (((abc)))
from *()*
from *test()*
from *:test()
from *:()
from *:test)
from remote1:test(),remote2:test

and use these also for other places where index names are used (enrich, lookup join, fork etc).

@luigidellaquila luigidellaquila changed the title ES|QL: Disallow brackets in unquoted index pattersn ES|QL: Disallow brackets in unquoted index patterns Jul 8, 2025
Copy link
Contributor

@astefan astefan 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

@astefan
Copy link
Contributor

astefan commented Jul 9, 2025

No 9.1 version backport? Just curious

@luigidellaquila
Copy link
Contributor Author

No 9.1 version backport?

We absolutely need to backport it to 9.1 as well, thanks for pointing it out.
Fixed!

@luigidellaquila
Copy link
Contributor Author

Actually, I think we want it only in 9.2, 9.1, and 8.19.
It's a bug fix, but it's breaking, so I'm not sure we want to port it further back.
I'm removing 9.0 label for now, in case I'll do further backports manually

@luigidellaquila luigidellaquila merged commit 71434e6 into elastic:main Jul 9, 2025
34 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts
9.1 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 130427

@luigidellaquila
Copy link
Contributor Author



---
"Enrich in fork":
Copy link
Contributor

Choose a reason for hiding this comment

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

this test is causing bwc test failures since FORK is not available in 8.19

mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 17, 2025
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged backport pending >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.19.0 v9.1.0 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ES|QL: parentheses in index names conflict with subquery syntax

5 participants