-
Notifications
You must be signed in to change notification settings - Fork 25.8k
ES|QL: Validate TOP_SNIPPETS query argument is foldable #142763
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
Changes from all commits
b18594a
8b44639
84c48a3
06009b7
810bb14
3cf533f
da9e449
472f982
b56254e
74b3044
a8767f4
f381874
9aae38f
00a317b
05c775f
0ad2083
e746564
a716cb4
7e51579
7f5f2a2
ef48273
f7f0179
058bd8c
4413d0c
ff2a08c
381895c
67012ad
ee39555
8d868b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| area: ES|QL | ||
| issues: | ||
| - 142462 | ||
| pr: 142763 | ||
| summary: Validate TOP_SNIPPETS query argument is foldable at verification | ||
| type: enhancement |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10335,4 +10335,16 @@ public void testCombineOrderByThroughRegisteredDomain() { | |
| var registeredDomain = as(topN.child(), RegisteredDomain.class); | ||
| as(registeredDomain.child(), EsRelation.class); | ||
| } | ||
|
|
||
| public void testTopSnippetsQueryMustBeFoldable() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I initially suggested to @mridula-s109 to add a similar test in VerifierTests, because we already had some tests that were checking for constant arguments. |
||
| VerificationException e = expectThrows(VerificationException.class, () -> plan(""" | ||
| FROM test | ||
| | EVAL x = TOP_SNIPPETS(first_name, last_name) | ||
| """)); | ||
| assertTrue(e.getMessage().startsWith("Found ")); | ||
| assertThat( | ||
| e.getMessage(), | ||
| containsString("second argument of [TOP_SNIPPETS(first_name, last_name)] must be a constant, received [last_name]") | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -730,3 +730,46 @@ Employee name in list: | |
| - match: { columns.2.name: "name" } | ||
| - length: { values: 1 } | ||
| - match: { values.0.2: "Alice Smith" } | ||
|
|
||
| --- | ||
| TOP_SNIPPETS with foldable query: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we need a capability for mixed clusters? Will this work when issued against an older cluster? 🤔 |
||
| - requires: | ||
| test_runner_features: [ capabilities ] | ||
| capabilities: | ||
| - method: POST | ||
| path: /_query | ||
| parameters: [ ] | ||
| capabilities: [ top_snippets_foldable_query_check ] | ||
| reason: "Uses TOP_SNIPPETS function" | ||
| - do: | ||
| esql.query: | ||
| body: | ||
| query: | | ||
| FROM employees | ||
| | EVAL x = TOP_SNIPPETS(name, CONCAT("search", " terms")) | ||
| | KEEP name, x | ||
| | LIMIT 1 | ||
| - match: { columns.0.name: "name" } | ||
| - match: { columns.1.name: "x" } | ||
| - length: { values: 1 } | ||
|
|
||
| --- | ||
| TOP_SNIPPETS with non-foldable query: | ||
| - requires: | ||
| test_runner_features: [ capabilities ] | ||
| capabilities: | ||
| - method: POST | ||
| path: /_query | ||
| parameters: [ ] | ||
| capabilities: [ top_snippets_foldable_query_check ] | ||
| reason: "Uses TOP_SNIPPETS function" | ||
| - do: | ||
| catch: bad_request | ||
| esql.query: | ||
| body: | ||
| query: | | ||
| FROM employees | ||
| | EVAL x = TOP_SNIPPETS(name, name) | ||
| | LIMIT 1 | ||
| - match: { error.type: "verification_exception" } | ||
| - contains: { error.reason: "second argument of [TOP_SNIPPETS(name, name)] must be a constant, received [name]" } | ||
Uh oh!
There was an error while loading. Please reload this page.