Skip to content

Commit dd57b36

Browse files
authored
Merge branch 'main' into ChrisHegarty-patch-1
2 parents d8bebdf + ccc3121 commit dd57b36

File tree

13 files changed

+188
-21
lines changed

13 files changed

+188
-21
lines changed

docs/changelog/127563.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 127563
2+
summary: "ESQL: Avoid unintended attribute removal"
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 127468

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyUtils.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public static Map<String, Policy> createPluginPolicies(
8181
return pluginPolicies;
8282
}
8383

84+
/**
85+
* @throws PolicyParserException if the supplied policy is formatted incorrectly
86+
* @throws IllegalStateException for any other error parsing the patch, such as nonexistent module names
87+
*/
8488
public static Policy parseEncodedPolicyIfExists(
8589
String encodedPolicy,
8690
String version,
@@ -106,11 +110,8 @@ public static Policy parseEncodedPolicyIfExists(
106110
version
107111
);
108112
}
109-
} catch (Exception ex) {
110-
logger.warn(
111-
Strings.format("Found a policy patch with invalid content. The patch will not be applied. Layer [%s]", layerName),
112-
ex
113-
);
113+
} catch (Exception e) {
114+
throw new IllegalStateException("Unable to parse policy patch for layer [" + layerName + "]", e);
114115
}
115116
}
116117
return null;

libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyUtilsTests.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public void testNoPatchWithVersionMismatch() {
134134

135135
public void testNoPatchWithValidationError() {
136136

137+
// Nonexistent module names
137138
var policyPatch = """
138139
versions:
139140
- 9.0.0
@@ -149,13 +150,15 @@ public void testNoPatchWithValidationError() {
149150
StandardCharsets.UTF_8
150151
);
151152

152-
var policy = PolicyUtils.parseEncodedPolicyIfExists(base64EncodedPolicy, "9.0.0", true, "test-plugin", Set.of());
153-
154-
assertThat(policy, nullValue());
153+
assertThrows(
154+
IllegalStateException.class,
155+
() -> PolicyUtils.parseEncodedPolicyIfExists(base64EncodedPolicy, "9.0.0", true, "test-plugin", Set.of())
156+
);
155157
}
156158

157159
public void testNoPatchWithParsingError() {
158160

161+
// no <version> or <policy> field
159162
var policyPatch = """
160163
entitlement-module-name:
161164
- load_native_libraries
@@ -167,9 +170,10 @@ public void testNoPatchWithParsingError() {
167170
StandardCharsets.UTF_8
168171
);
169172

170-
var policy = PolicyUtils.parseEncodedPolicyIfExists(base64EncodedPolicy, "9.0.0", true, "test-plugin", Set.of());
171-
172-
assertThat(policy, nullValue());
173+
assertThrows(
174+
IllegalStateException.class,
175+
() -> PolicyUtils.parseEncodedPolicyIfExists(base64EncodedPolicy, "9.0.0", true, "test-plugin", Set.of())
176+
);
173177
}
174178

175179
public void testMergeScopes() {

muted-tests.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,15 @@ tests:
453453
- class: org.elasticsearch.packaging.test.DockerTests
454454
method: test041AmazonCaCertsAreInTheKeystore
455455
issue: https://github.com/elastic/elasticsearch/issues/128006
456+
- class: org.elasticsearch.packaging.test.DockerTests
457+
method: test130JavaHasCorrectOwnership
458+
issue: https://github.com/elastic/elasticsearch/issues/128174
459+
- class: org.elasticsearch.packaging.test.DockerTests
460+
method: test600Interrupt
461+
issue: https://github.com/elastic/elasticsearch/issues/128144
462+
- class: org.elasticsearch.packaging.test.EnrollmentProcessTests
463+
method: test20DockerAutoFormCluster
464+
issue: https://github.com/elastic/elasticsearch/issues/128113
456465

457466
# Examples:
458467
#

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ static TransportVersion def(int id) {
177177
public static final TransportVersion ESQL_DRIVER_TASK_DESCRIPTION_8_19 = def(8_841_0_30);
178178
public static final TransportVersion ML_INFERENCE_HUGGING_FACE_CHAT_COMPLETION_ADDED_8_19 = def(8_841_0_31);
179179
public static final TransportVersion V_8_19_FIELD_CAPS_ADD_CLUSTER_ALIAS = def(8_841_0_32);
180+
public static final TransportVersion ESQL_HASH_OPERATOR_STATUS_OUTPUT_TIME_8_19 = def(8_841_0_34);
180181
public static final TransportVersion V_9_0_0 = def(9_000_0_09);
181182
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_1 = def(9_000_0_10);
182183
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_2 = def(9_000_0_11);

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/HashAggregationOperator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ protected Status(StreamInput in) throws IOException {
359359
rowsReceived = 0;
360360
rowsEmitted = 0;
361361
}
362-
if (in.getTransportVersion().onOrAfter(TransportVersions.ESQL_HASH_OPERATOR_STATUS_OUTPUT_TIME)) {
362+
if (in.getTransportVersion().onOrAfter(TransportVersions.ESQL_HASH_OPERATOR_STATUS_OUTPUT_TIME)
363+
|| in.getTransportVersion().isPatchFrom(TransportVersions.ESQL_HASH_OPERATOR_STATUS_OUTPUT_TIME_8_19)) {
363364
emitNanos = in.readVLong();
364365
} else {
365366
emitNanos = 0;
@@ -376,7 +377,8 @@ public void writeTo(StreamOutput out) throws IOException {
376377
out.writeVLong(rowsReceived);
377378
out.writeVLong(rowsEmitted);
378379
}
379-
if (out.getTransportVersion().onOrAfter(TransportVersions.ESQL_HASH_OPERATOR_STATUS_OUTPUT_TIME)) {
380+
if (out.getTransportVersion().onOrAfter(TransportVersions.ESQL_HASH_OPERATOR_STATUS_OUTPUT_TIME)
381+
|| out.getTransportVersion().isPatchFrom(TransportVersions.ESQL_HASH_OPERATOR_STATUS_OUTPUT_TIME_8_19)) {
380382
out.writeVLong(emitNanos);
381383
}
382384
}

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeRestTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public abstract class GenerativeRestTest extends ESRestTestCase {
5151
"Unknown column \\[<all-fields-projected>\\]", // https://github.com/elastic/elasticsearch/issues/121741,
5252
"Plan \\[ProjectExec\\[\\[<no-fields>.* optimized incorrectly due to missing references", // https://github.com/elastic/elasticsearch/issues/125866
5353
"optimized incorrectly due to missing references", // https://github.com/elastic/elasticsearch/issues/116781
54-
"only supports KEYWORD or TEXT values", // https://github.com/elastic/elasticsearch/issues/127468
5554
"The incoming YAML document exceeds the limit:" // still to investigate, but it seems to be specific to the test framework
5655
);
5756

x-pack/plugin/esql/qa/testFixtures/src/main/resources/dissect.csv-spec

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,43 @@ ROW a="b c d x"| DISSECT a "%{b} %{} %{d} %{}";
331331
a:keyword | b:keyword | d:keyword
332332
b c d x | b | d
333333
;
334+
335+
avoidAttributesRemoval
336+
// https://github.com/elastic/elasticsearch/issues/127468
337+
required_capability: keep_regex_extract_attributes
338+
required_capability: join_lookup_v12
339+
from message_types
340+
| eval type = 1
341+
| lookup join message_types_lookup on message
342+
| drop message
343+
| dissect type "%{b}"
344+
| stats x = max(b)
345+
| keep x
346+
;
347+
348+
x:keyword
349+
Success
350+
;
351+
352+
avoidAttributesRemoval2
353+
// https://github.com/elastic/elasticsearch/issues/127468
354+
required_capability: keep_regex_extract_attributes
355+
required_capability: join_lookup_v12
356+
FROM sample_data, employees
357+
| EVAL client_ip = client_ip::keyword
358+
| RENAME languages AS language_code
359+
| LOOKUP JOIN clientips_lookup ON client_ip
360+
| EVAL type = 1::keyword
361+
| EVAL type = 2
362+
| LOOKUP JOIN message_types_lookup ON message
363+
| LOOKUP JOIN languages_lookup ON language_code
364+
| DISSECT type "%{type_as_text}"
365+
| KEEP message
366+
| WHERE message IS NOT NULL
367+
| SORT message DESC
368+
| LIMIT 1
369+
;
370+
371+
message:keyword
372+
Disconnected
373+
;

x-pack/plugin/esql/qa/testFixtures/src/main/resources/grok.csv-spec

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,35 @@ row text = "123 abc", int = 5 | sort int asc | grok text "%{NUMBER:text:int} %{W
297297
text:integer | int:integer | description:keyword
298298
123 | 5 | abc
299299
;
300+
301+
avoidAttributesRemoval
302+
// https://github.com/elastic/elasticsearch/issues/127468
303+
required_capability: union_types
304+
required_capability: join_lookup_v12
305+
required_capability: keep_regex_extract_attributes
306+
from multivalue_points,h*,messa*
307+
| eval `card` = true, PbehoQUqKSF = "VLGjhcgNkQiEVyCLo", DsxMWtGL = true, qSxTIvUorMim = true, `location` = 8593178066470220111, type = -446161601, FSkGQkgmS = false
308+
| eval PbehoQUqKSF = 753987034, HLNMQfQj = true, `within` = true, `id` = "JDKKkYwhhh", lk = null, aecuvjTkgZza = 510616700, aDAMpuVtNX = null, qCopgNZPt = "AjhJUtZefqKdJYH", BxHHlFoA = "isBrmhKLc"
309+
| rename message as message
310+
| lookup join message_types_lookup on message
311+
| sort PbehoQUqKSF DESC, ip1 DESC NULLS LAST
312+
| limit 5845
313+
| drop `subset`, ip*, `card`, `within`, host.v*, description, `aecuvjTkgZza`, host.version, `ip0`, height_range, DsxMWtGL, host_group, `aDAMpuVtNX`, PbehoQUqKSF, `intersects`, `host.os`, aDAMpuVtNX, *ight_range, HLNMQfQj, `FSkGQkgmS`, BxHHlFoA, card
314+
| grok type "%{WORD:GknCxQFo}"
315+
| eval `location` = null, ZjWUUvGusyyz = null, HeeKIpzgh = false, `id` = 4325287503714500302, host = false, `lk` = null, HvTQdOqFajpH = false, fKNlsYoT = true, `location` = -1158449473, `qCopgNZPt` = 1219986202615280617
316+
| drop HeeKIpzg*, `ZjWUUvGusyyz`, `message`, `type`, `lk`
317+
| grok GknCxQFo "%{WORD:location} %{WORD:HvTQdOqFajpH}"
318+
| drop HvTQdOqFajpH, `location`, centroid
319+
| mv_expand GknCxQFo
320+
| limit 410
321+
| limit 3815
322+
| rename `id` AS `GknCxQFo`
323+
| grok host.name "%{WORD:oGQQZHxQHj} %{WORD:qCopgNZPt} %{WORD:vHKOmmocPcTO}"
324+
| stats BkQXJRMeAM = min(GknCxQFo)
325+
| keep `BkQXJRMeAM`
326+
;
327+
328+
BkQXJRMeAM:long
329+
4325287503714500302
330+
;
331+

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ManyShardsIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ public void testCancelUnnecessaryRequests() {
281281
query.query("from test-* | LIMIT 1");
282282
query.pragmas(new QueryPragmas(Settings.builder().put(QueryPragmas.MAX_CONCURRENT_NODES_PER_CLUSTER.getKey(), 1).build()));
283283

284-
try {
285-
var result = safeExecute(client(coordinatingNode), EsqlQueryAction.INSTANCE, query);
284+
try (var result = safeGet(client().execute(EsqlQueryAction.INSTANCE, query))) {
286285
assertThat(Iterables.size(result.rows()), equalTo(1L));
287286
assertThat(exchanges.get(), lessThanOrEqualTo(2));
288287
} finally {

0 commit comments

Comments
 (0)