Skip to content

Commit ef0a177

Browse files
authored
ESQL: Disable a bugged commit (#127199)
The PR #126641 has a bug with `!=`.
1 parent a5b33b9 commit ef0a177

File tree

5 files changed

+73
-11
lines changed

5 files changed

+73
-11
lines changed

docs/changelog/127199.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 127199
2+
summary: Disable a bugged commit
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 127197

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/PushQueriesIT.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,48 @@ public void testPushEqualityOnDefaults() throws IOException {
5252
testPushQuery(value, """
5353
FROM test
5454
| WHERE test == "%value"
55-
""", "#test.keyword:%value -_ignored:test.keyword", false);
55+
""", "*:*", true, true);
5656
}
5757

5858
public void testPushEqualityOnDefaultsTooBigToPush() throws IOException {
5959
String value = "a".repeat(between(257, 1000));
6060
testPushQuery(value, """
6161
FROM test
6262
| WHERE test == "%value"
63-
""", "*:*", true);
63+
""", "*:*", true, true);
64+
}
65+
66+
public void testPushInequalityOnDefaults() throws IOException {
67+
String value = "v".repeat(between(0, 256));
68+
testPushQuery(value, """
69+
FROM test
70+
| WHERE test != "%different_value"
71+
""", "*:*", true, true);
72+
}
73+
74+
public void testPushInequalityOnDefaultsTooBigToPush() throws IOException {
75+
String value = "a".repeat(between(257, 1000));
76+
testPushQuery(value, """
77+
FROM test
78+
| WHERE test != "%value"
79+
""", "*:*", true, false);
6480
}
6581

6682
public void testPushCaseInsensitiveEqualityOnDefaults() throws IOException {
6783
String value = "a".repeat(between(0, 256));
6884
testPushQuery(value, """
6985
FROM test
7086
| WHERE TO_LOWER(test) == "%value"
71-
""", "*:*", true);
87+
""", "*:*", true, true);
7288
}
7389

74-
private void testPushQuery(String value, String esqlQuery, String luceneQuery, boolean filterInCompute) throws IOException {
90+
private void testPushQuery(String value, String esqlQuery, String luceneQuery, boolean filterInCompute, boolean found)
91+
throws IOException {
7592
indexValue(value);
93+
String differentValue = randomValueOtherThan(value, () -> randomAlphaOfLength(value.length()));
7694

77-
RestEsqlTestCase.RequestObjectBuilder builder = requestObjectBuilder().query(
78-
esqlQuery.replaceAll("%value", value) + "\n| KEEP test"
79-
);
95+
String replacedQuery = esqlQuery.replaceAll("%value", value).replaceAll("%different_value", differentValue);
96+
RestEsqlTestCase.RequestObjectBuilder builder = requestObjectBuilder().query(replacedQuery + "\n| KEEP test");
8097
builder.profile(true);
8198
Map<String, Object> result = runEsql(builder, new AssertWarnings.NoWarnings(), RestEsqlTestCase.Mode.SYNC);
8299
assertResultMap(
@@ -88,7 +105,7 @@ private void testPushQuery(String value, String esqlQuery, String luceneQuery, b
88105
.entry("query", matchesMap().extraOk())
89106
),
90107
matchesList().item(matchesMap().entry("name", "test").entry("type", "text")),
91-
equalTo(List.of(List.of(value)))
108+
equalTo(found ? List.of(List.of(value)) : List.of())
92109
);
93110

94111
@SuppressWarnings("unchecked")
@@ -100,7 +117,7 @@ private void testPushQuery(String value, String esqlQuery, String luceneQuery, b
100117
@SuppressWarnings("unchecked")
101118
List<Map<String, Object>> operators = (List<Map<String, Object>>) p.get("operators");
102119
for (Map<String, Object> o : operators) {
103-
sig.add(checkOperatorProfile(o, luceneQuery.replaceAll("%value", value)));
120+
sig.add(checkOperatorProfile(o, luceneQuery.replaceAll("%value", value).replaceAll("%different_value", differentValue)));
104121
}
105122
String description = p.get("description").toString();
106123
switch (description) {

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,3 +2332,40 @@ warning:Line 2:9: java.lang.IllegalArgumentException: single-value function enco
23322332
@timestamp:date | message:text
23332333
2023-10-23T13:55:01.546Z|More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100
23342334
;
2335+
2336+
mvStringNotEquals
2337+
FROM mv_text
2338+
| WHERE message != "Connected to 10.1.0.2"
2339+
| KEEP @timestamp, message
2340+
;
2341+
warning:Line 2:9: evaluation of [message != \"Connected to 10.1.0.2\"] failed, treating result as null. Only first 20 failures recorded.
2342+
warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value
2343+
2344+
@timestamp:date | message:text
2345+
2023-10-23T13:55:01.544Z|Connected to 10.1.0.1
2346+
2023-10-23T13:55:01.546Z|More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100
2347+
;
2348+
2349+
mvStringNotEqualsFound
2350+
FROM mv_text
2351+
| WHERE message != "Connected to 10.1.0.1"
2352+
| KEEP @timestamp, message
2353+
;
2354+
warning:Line 2:9: evaluation of [message != \"Connected to 10.1.0.1\"] failed, treating result as null. Only first 20 failures recorded.
2355+
warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value
2356+
2357+
@timestamp:date | message:text
2358+
2023-10-23T13:55:01.546Z|More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100
2359+
;
2360+
2361+
mvStringNotEqualsLong
2362+
FROM mv_text
2363+
| WHERE message != "More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100"
2364+
| KEEP @timestamp, message
2365+
;
2366+
warning:Line 2:9: evaluation of [message != \"More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100\"] failed, treating result as null. Only first 20 failures recorded.
2367+
warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value
2368+
2369+
@timestamp:date | message:text
2370+
2023-10-23T13:55:01.544Z|Connected to 10.1.0.1
2371+
;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public Equals(Source source, Expression left, Expression right, ZoneId zoneId) {
130130
@Override
131131
public boolean translatable(LucenePushdownPredicates pushdownPredicates) {
132132
if (right() instanceof Literal lit) {
133-
if (left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
133+
if (false && left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
134134
if (pushdownPredicates.canUseEqualityOnSyntheticSourceDelegate(fa, ((BytesRef) lit.value()).utf8ToString())) {
135135
return true;
136136
}
@@ -142,7 +142,8 @@ public boolean translatable(LucenePushdownPredicates pushdownPredicates) {
142142
@Override
143143
public Query asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHandler handler) {
144144
if (right() instanceof Literal lit) {
145-
if (left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
145+
// Disabled because it cased a bug with !=. Fix incoming shortly.
146+
if (false && left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
146147
String value = ((BytesRef) lit.value()).utf8ToString();
147148
if (pushdownPredicates.canUseEqualityOnSyntheticSourceDelegate(fa, value)) {
148149
String name = handler.nameOf(fa);

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PhysicalPlanOptimizerTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7793,6 +7793,7 @@ public void testReductionPlanForAggs() {
77937793
}
77947794

77957795
public void testEqualsPushdownToDelegate() {
7796+
assumeFalse("disabled from bug", true);
77967797
var optimized = optimizedPlan(physicalPlan("""
77977798
FROM test
77987799
| WHERE job == "v"

0 commit comments

Comments
 (0)