-
Notifications
You must be signed in to change notification settings - Fork 25.7k
ESQL: Handle release of 9.2 in test #137070
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6b254ed
ESQL: Handle release of 9.2 in test
nik9000 3a099a5
Merge branch 'main' into esql_created_field_more_test
nik9000 48c373c
Document relevant transport versions better
alex-spies eede45b
Merge branch 'main' into esql_created_field_more_test
nik9000 0da47df
Merge remote-tracking branch 'nik9000/esql_created_field_more_test' i…
nik9000 c38129c
Merge branch 'main' into esql_created_field_more_test
nik9000 b6887e5
Merge branch 'main' into esql_created_field_more_test
nik9000 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
1 change: 1 addition & 0 deletions
1
.../src/main/resources/transport/definitions/referable/esql_resolve_fields_response_used.csv
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 @@ | ||
| 9204000,9185005 |
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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| min_transport_version,9185004 | ||
| esql_resolve_fields_response_used,9185005 |
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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| esql_resolve_fields_response_removed_min_tv,9203000 | ||
| esql_resolve_fields_response_used,9204000 |
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 |
|---|---|---|
|
|
@@ -44,7 +44,10 @@ | |
| import static org.elasticsearch.test.ListMatcher.matchesList; | ||
| import static org.elasticsearch.test.MapMatcher.assertMap; | ||
| import static org.elasticsearch.test.MapMatcher.matchesMap; | ||
| import static org.elasticsearch.xpack.esql.action.EsqlResolveFieldsResponse.RESOLVE_FIELDS_RESPONSE_CREATED_TV; | ||
| import static org.elasticsearch.xpack.esql.action.EsqlResolveFieldsResponse.RESOLVE_FIELDS_RESPONSE_USED_TV; | ||
| import static org.elasticsearch.xpack.esql.core.type.DataType.DataTypesTransportVersions.ESQL_AGGREGATE_METRIC_DOUBLE_CREATED_VERSION; | ||
| import static org.elasticsearch.xpack.esql.core.type.DataType.DataTypesTransportVersions.ESQL_DENSE_VECTOR_CREATED_VERSION; | ||
| import static org.elasticsearch.xpack.esql.core.type.DataType.DataTypesTransportVersions.INDEX_SOURCE; | ||
| import static org.hamcrest.Matchers.any; | ||
| import static org.hamcrest.Matchers.anyOf; | ||
| import static org.hamcrest.Matchers.containsString; | ||
|
|
@@ -71,8 +74,6 @@ | |
| public class AllSupportedFieldsTestCase extends ESRestTestCase { | ||
| private static final Logger logger = LogManager.getLogger(FieldExtractorTestCase.class); | ||
|
|
||
| private static final TransportVersion INDEX_SOURCE = TransportVersion.fromName("index_source"); | ||
|
|
||
| @Rule(order = Integer.MIN_VALUE) | ||
| public ProfileLogger profileLogger = new ProfileLogger(); | ||
|
|
||
|
|
@@ -329,6 +330,76 @@ public final void testFetchDenseVector() throws IOException { | |
| assertMap(indexToRow(columns, values), expectedAllValues); | ||
| } | ||
|
|
||
| /** | ||
| * Tests fetching {@code aggregate_metric_double} if possible. Uses the {@code dense_vector_agg_metric_double_if_fns} | ||
| * work around if required. | ||
| */ | ||
| public final void testFetchAggregateMetricDouble() throws IOException { | ||
| Map<String, Object> response; | ||
| try { | ||
| String request = """ | ||
| | EVAL strjunk = TO_STRING(f_aggregate_metric_double) | ||
| | KEEP _index, f_aggregate_metric_double | ||
| | LIMIT 1000 | ||
| """; | ||
| if (denseVectorAggMetricDoubleIfVersion() == false) { | ||
| request = """ | ||
| | EVAL junk = TO_AGGREGATE_METRIC_DOUBLE(1) // workaround to enable fetching aggregate_metric_double | ||
| """ + request; | ||
| } | ||
| response = esql(request); | ||
| if ((Boolean) response.get("is_partial")) { | ||
| Map<?, ?> clusters = (Map<?, ?>) response.get("_clusters"); | ||
| Map<?, ?> details = (Map<?, ?>) clusters.get("details"); | ||
|
|
||
| boolean foundError = false; | ||
| for (Map.Entry<?, ?> cluster : details.entrySet()) { | ||
| String failures = cluster.getValue().toString(); | ||
| if (denseVectorAggMetricDoubleIfFns()) { | ||
| throw new AssertionError("should correctly fetch the aggregate_metric_double: " + failures); | ||
| } | ||
| foundError |= failures.contains("doesn't understand data type [AGGREGATE_METRIC_DOUBLE]"); | ||
| } | ||
| assertTrue("didn't find errors: " + details, foundError); | ||
| return; | ||
| } | ||
| } catch (ResponseException e) { | ||
| if (denseVectorAggMetricDoubleIfFns()) { | ||
| throw new AssertionError("should correctly fetch the aggregate_metric_double", e); | ||
| } | ||
| assertThat( | ||
| "old version should fail with this error", | ||
| EntityUtils.toString(e.getResponse().getEntity()), | ||
| anyOf( | ||
| containsString("Unknown function [TO_AGGREGATE_METRIC_DOUBLE]"), | ||
| containsString("Cannot use field [f_aggregate_metric_double] with unsupported type"), | ||
| containsString("doesn't understand data type [AGGREGATE_METRIC_DOUBLE]") | ||
| ) | ||
| ); | ||
| // Failure is expected and fine | ||
| return; | ||
| } | ||
| List<?> columns = (List<?>) response.get("columns"); | ||
| List<?> values = (List<?>) response.get("values"); | ||
|
|
||
| MapMatcher expectedColumns = matchesMap().entry("f_aggregate_metric_double", "aggregate_metric_double").entry("_index", "keyword"); | ||
| assertMap(nameToType(columns), expectedColumns); | ||
|
|
||
| MapMatcher expectedAllValues = matchesMap(); | ||
| for (Map.Entry<String, NodeInfo> e : expectedIndices().entrySet()) { | ||
| String indexName = e.getKey(); | ||
| NodeInfo nodeInfo = e.getValue(); | ||
| MapMatcher expectedValues = matchesMap(); | ||
| expectedValues = expectedValues.entry( | ||
| "f_aggregate_metric_double", | ||
| "{\"min\":-302.5,\"max\":702.3,\"sum\":200.0,\"value_count\":25}" | ||
| ); | ||
| expectedValues = expectedValues.entry("_index", indexName); | ||
| expectedAllValues = expectedAllValues.entry(indexName, expectedValues); | ||
| } | ||
| assertMap(indexToRow(columns, values), expectedAllValues); | ||
| } | ||
|
|
||
| private Map<String, Object> esql(String query) throws IOException { | ||
| Request request = new Request("POST", "_query"); | ||
| XContentBuilder body = JsonXContent.contentBuilder().startObject(); | ||
|
|
@@ -473,21 +544,15 @@ private Matcher<?> expectedValue(DataType type, NodeInfo nodeInfo) throws IOExce | |
| case GEO_SHAPE -> equalTo("POINT (-71.34 41.12)"); | ||
| case NULL -> nullValue(); | ||
| case AGGREGATE_METRIC_DOUBLE -> { | ||
| /* | ||
| * We need both AGGREGATE_METRIC_DOUBLE_CREATED and RESOLVE_FIELDS_RESPONSE_CREATED_TV | ||
| * but RESOLVE_FIELDS_RESPONSE_CREATED_TV came last so it's enough to check just it. | ||
| */ | ||
| if (minVersion().supports(RESOLVE_FIELDS_RESPONSE_CREATED_TV) == false) { | ||
| if (minVersion().supports(RESOLVE_FIELDS_RESPONSE_USED_TV) == false | ||
| || minVersion().supports(ESQL_AGGREGATE_METRIC_DOUBLE_CREATED_VERSION) == false) { | ||
| yield nullValue(); | ||
| } | ||
| yield equalTo("{\"min\":-302.5,\"max\":702.3,\"sum\":200.0,\"value_count\":25}"); | ||
| } | ||
| case DENSE_VECTOR -> { | ||
| /* | ||
| * We need both DENSE_VECTOR_CREATED and RESOLVE_FIELDS_RESPONSE_CREATED_TV | ||
| * but RESOLVE_FIELDS_RESPONSE_CREATED_TV came last so it's enough to check just it. | ||
| */ | ||
| if (minVersion().supports(RESOLVE_FIELDS_RESPONSE_CREATED_TV) == false) { | ||
| if (minVersion().supports(RESOLVE_FIELDS_RESPONSE_USED_TV) == false | ||
| || minVersion().supports(ESQL_DENSE_VECTOR_CREATED_VERSION) == false) { | ||
| yield nullValue(); | ||
| } | ||
| yield equalTo(List.of(0.5, 10.0, 5.9999995)); | ||
|
|
@@ -574,15 +639,24 @@ private Matcher<String> expectedType(DataType type) throws IOException { | |
| case BYTE, SHORT -> equalTo("integer"); | ||
| case HALF_FLOAT, SCALED_FLOAT, FLOAT -> equalTo("double"); | ||
| case NULL -> equalTo("keyword"); | ||
| case AGGREGATE_METRIC_DOUBLE, DENSE_VECTOR -> { | ||
| /* | ||
| * We need both <type_name>_CREATED and RESOLVE_FIELDS_RESPONSE_CREATED_TV | ||
| * but RESOLVE_FIELDS_RESPONSE_CREATED_TV came last so it's enough to check just it. | ||
| */ | ||
| if (minVersion().supports(RESOLVE_FIELDS_RESPONSE_CREATED_TV) == false) { | ||
| case AGGREGATE_METRIC_DOUBLE -> { | ||
| // RESOLVE_FIELDS_RESPONSE_USED_TV is newer and technically sufficient to check. | ||
| // We also check for ESQL_AGGREGATE_METRIC_DOUBLE_CREATED_VERSION for clarity. | ||
| // Future data types added here should only require the TV when they were created, | ||
| // because it will be after RESOLVE_FIELDS_RESPONSE_USED_TV. | ||
| if (minVersion().supports(RESOLVE_FIELDS_RESPONSE_USED_TV) == false | ||
| || minVersion().supports(ESQL_AGGREGATE_METRIC_DOUBLE_CREATED_VERSION) == false) { | ||
| yield equalTo("unsupported"); | ||
| } | ||
| yield equalTo("aggregate_metric_double"); | ||
| } | ||
| case DENSE_VECTOR -> { | ||
| logger.error("ADFDAFAF " + minVersion()); | ||
|
Contributor
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. Leftover?
Member
Author
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. yup. will zap |
||
| if (minVersion().supports(RESOLVE_FIELDS_RESPONSE_USED_TV) == false | ||
| || minVersion().supports(ESQL_DENSE_VECTOR_CREATED_VERSION) == false) { | ||
| yield equalTo("unsupported"); | ||
| } | ||
| yield equalTo(type.esType()); | ||
| yield equalTo("dense_vector"); | ||
| } | ||
| default -> equalTo(type.esType()); | ||
| }; | ||
|
|
||
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
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.
Is this needed? There's more junk below to trigger the workaround, and this is not kept.
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'll leave a comment - yeah, it is.