Skip to content

Commit 40000c7

Browse files
committed
ESQL: Disable a bugged commit (elastic#127199)
The PR elastic#126641 has a bug with `!=`.
1 parent c59b7d9 commit 40000c7

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,38 +52,55 @@ 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(
83100
result,
84101
getResultMatcher(result).entry("profile", matchesMap().entry("drivers", instanceOf(List.class))),
85102
matchesList().item(matchesMap().entry("name", "test").entry("type", "text")),
86-
equalTo(List.of(List.of(value)))
103+
equalTo(found ? List.of(List.of(value)) : List.of())
87104
);
88105

89106
@SuppressWarnings("unchecked")
@@ -95,7 +112,7 @@ private void testPushQuery(String value, String esqlQuery, String luceneQuery, b
95112
@SuppressWarnings("unchecked")
96113
List<Map<String, Object>> operators = (List<Map<String, Object>>) p.get("operators");
97114
for (Map<String, Object> o : operators) {
98-
sig.add(checkOperatorProfile(o, luceneQuery.replaceAll("%value", value)));
115+
sig.add(checkOperatorProfile(o, luceneQuery.replaceAll("%value", value).replaceAll("%different_value", differentValue)));
99116
}
100117
String description = p.get("task_description").toString();
101118
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
@@ -2326,3 +2326,40 @@ warning:Line 2:9: java.lang.IllegalArgumentException: single-value function enco
23262326
@timestamp:date | message:text
23272327
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
23282328
;
2329+
2330+
mvStringNotEquals
2331+
FROM mv_text
2332+
| WHERE message != "Connected to 10.1.0.2"
2333+
| KEEP @timestamp, message
2334+
;
2335+
warning:Line 2:9: evaluation of [message != \"Connected to 10.1.0.2\"] failed, treating result as null. Only first 20 failures recorded.
2336+
warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value
2337+
2338+
@timestamp:date | message:text
2339+
2023-10-23T13:55:01.544Z|Connected to 10.1.0.1
2340+
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
2341+
;
2342+
2343+
mvStringNotEqualsFound
2344+
FROM mv_text
2345+
| WHERE message != "Connected to 10.1.0.1"
2346+
| KEEP @timestamp, message
2347+
;
2348+
warning:Line 2:9: evaluation of [message != \"Connected to 10.1.0.1\"] failed, treating result as null. Only first 20 failures recorded.
2349+
warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value
2350+
2351+
@timestamp:date | message:text
2352+
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
2353+
;
2354+
2355+
mvStringNotEqualsLong
2356+
FROM mv_text
2357+
| WHERE message != "More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100"
2358+
| KEEP @timestamp, message
2359+
;
2360+
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.
2361+
warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value
2362+
2363+
@timestamp:date | message:text
2364+
2023-10-23T13:55:01.544Z|Connected to 10.1.0.1
2365+
;

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
@@ -131,7 +131,7 @@ public Equals(Source source, Expression left, Expression right, ZoneId zoneId) {
131131
@Override
132132
public boolean translatable(LucenePushdownPredicates pushdownPredicates) {
133133
if (right() instanceof Literal lit) {
134-
if (left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
134+
if (false && left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
135135
if (pushdownPredicates.canUseEqualityOnSyntheticSourceDelegate(fa, ((BytesRef) lit.value()).utf8ToString())) {
136136
return true;
137137
}
@@ -143,7 +143,8 @@ public boolean translatable(LucenePushdownPredicates pushdownPredicates) {
143143
@Override
144144
public Query asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHandler handler) {
145145
if (right() instanceof Literal lit) {
146-
if (left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
146+
// Disabled because it cased a bug with !=. Fix incoming shortly.
147+
if (false && left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
147148
String value = ((BytesRef) lit.value()).utf8ToString();
148149
if (pushdownPredicates.canUseEqualityOnSyntheticSourceDelegate(fa, value)) {
149150
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
@@ -7696,6 +7696,7 @@ public void testReductionPlanForAggs() {
76967696
}
76977697

76987698
public void testEqualsPushdownToDelegate() {
7699+
assumeFalse("disabled from bug", true);
76997700
var optimized = optimizedPlan(physicalPlan("""
77007701
FROM test
77017702
| WHERE job == "v"

0 commit comments

Comments
 (0)