From 7b77c9a0db7794ac398078085cb5743119be39d7 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 22 Apr 2025 18:35:53 -0400 Subject: [PATCH 1/2] ESQL: Disable a bugged commit The PR #126641 has a bug with `!=`. --- .../esql/qa/single_node/PushQueriesIT.java | 35 +++++++++++++----- .../src/main/resources/string.csv-spec | 37 +++++++++++++++++++ .../predicate/operator/comparison/Equals.java | 5 ++- .../optimizer/PhysicalPlanOptimizerTests.java | 1 + 4 files changed, 67 insertions(+), 11 deletions(-) diff --git a/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/PushQueriesIT.java b/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/PushQueriesIT.java index 6d264c83c4239..1e7ce903ad8df 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/PushQueriesIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/PushQueriesIT.java @@ -52,7 +52,7 @@ public void testPushEqualityOnDefaults() throws IOException { testPushQuery(value, """ FROM test | WHERE test == "%value" - """, "#test.keyword:%value -_ignored:test.keyword", false); + """, "*:*", true, true); } public void testPushEqualityOnDefaultsTooBigToPush() throws IOException { @@ -60,7 +60,23 @@ public void testPushEqualityOnDefaultsTooBigToPush() throws IOException { testPushQuery(value, """ FROM test | WHERE test == "%value" - """, "*:*", true); + """, "*:*", true, true); + } + + public void testPushInequalityOnDefaults() throws IOException { + String value = "v".repeat(between(0, 256)); + testPushQuery(value, """ + FROM test + | WHERE test != "%different_value" + """, "*:*", true, true); + } + + public void testPushInequalityOnDefaultsTooBigToPush() throws IOException { + String value = "a".repeat(between(257, 1000)); + testPushQuery(value, """ + FROM test + | WHERE test != "%value" + """, "*:*", true, false); } public void testPushCaseInsensitiveEqualityOnDefaults() throws IOException { @@ -68,15 +84,16 @@ public void testPushCaseInsensitiveEqualityOnDefaults() throws IOException { testPushQuery(value, """ FROM test | WHERE TO_LOWER(test) == "%value" - """, "*:*", true); + """, "*:*", true, true); } - private void testPushQuery(String value, String esqlQuery, String luceneQuery, boolean filterInCompute) throws IOException { + private void testPushQuery(String value, String esqlQuery, String luceneQuery, boolean filterInCompute, boolean found) + throws IOException { indexValue(value); + String differentValue = randomValueOtherThan(value, () -> randomAlphaOfLength(value.length())); - RestEsqlTestCase.RequestObjectBuilder builder = requestObjectBuilder().query( - esqlQuery.replaceAll("%value", value) + "\n| KEEP test" - ); + String replacedQuery = esqlQuery.replaceAll("%value", value).replaceAll("%different_value", differentValue); + RestEsqlTestCase.RequestObjectBuilder builder = requestObjectBuilder().query(replacedQuery + "\n| KEEP test"); builder.profile(true); Map result = runEsql(builder, new AssertWarnings.NoWarnings(), RestEsqlTestCase.Mode.SYNC); assertResultMap( @@ -88,7 +105,7 @@ private void testPushQuery(String value, String esqlQuery, String luceneQuery, b .entry("query", matchesMap().extraOk()) ), matchesList().item(matchesMap().entry("name", "test").entry("type", "text")), - equalTo(List.of(List.of(value))) + equalTo(found ? List.of(List.of(value)) : List.of()) ); @SuppressWarnings("unchecked") @@ -100,7 +117,7 @@ private void testPushQuery(String value, String esqlQuery, String luceneQuery, b @SuppressWarnings("unchecked") List> operators = (List>) p.get("operators"); for (Map o : operators) { - sig.add(checkOperatorProfile(o, luceneQuery.replaceAll("%value", value))); + sig.add(checkOperatorProfile(o, luceneQuery.replaceAll("%value", value).replaceAll("%different_value", differentValue))); } String description = p.get("description").toString(); switch (description) { diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/string.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/string.csv-spec index 53b4d8c606a81..9f1d149c6fef7 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/string.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/string.csv-spec @@ -2332,3 +2332,40 @@ warning:Line 2:9: java.lang.IllegalArgumentException: single-value function enco @timestamp:date | message:text 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 ; + +mvStringNotEquals +FROM mv_text +| WHERE message != "Connected to 10.1.0.2" +| KEEP @timestamp, message +; +warning:Line 2:9: evaluation of [message != \"Connected to 10.1.0.2\"] failed, treating result as null. Only first 20 failures recorded. +warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value + + @timestamp:date | message:text +2023-10-23T13:55:01.544Z|Connected to 10.1.0.1 +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 +; + +mvStringNotEqualsFound +FROM mv_text +| WHERE message != "Connected to 10.1.0.1" +| KEEP @timestamp, message +; +warning:Line 2:9: evaluation of [message != \"Connected to 10.1.0.1\"] failed, treating result as null. Only first 20 failures recorded. +warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value + + @timestamp:date | message:text +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 +; + +mvStringNotEqualsLong +FROM mv_text +| WHERE message != "More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100" +| KEEP @timestamp, message +; +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. +warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value + + @timestamp:date | message:text +2023-10-23T13:55:01.544Z|Connected to 10.1.0.1 +; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java index d00d276ce228b..75f47615bad6e 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java @@ -130,7 +130,7 @@ public Equals(Source source, Expression left, Expression right, ZoneId zoneId) { @Override public boolean translatable(LucenePushdownPredicates pushdownPredicates) { if (right() instanceof Literal lit) { - if (left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) { + if (false && left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) { if (pushdownPredicates.canUseEqualityOnSyntheticSourceDelegate(fa, ((BytesRef) lit.value()).utf8ToString())) { return true; } @@ -142,7 +142,8 @@ public boolean translatable(LucenePushdownPredicates pushdownPredicates) { @Override public Query asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHandler handler) { if (right() instanceof Literal lit) { - if (left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) { + // Disabled because it cased a bug with !=. Fix incoming shortly. + if (false && left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) { String value = ((BytesRef) lit.value()).utf8ToString(); if (pushdownPredicates.canUseEqualityOnSyntheticSourceDelegate(fa, value)) { String name = handler.nameOf(fa); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PhysicalPlanOptimizerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PhysicalPlanOptimizerTests.java index 88fa6d2605138..64a281718ae8c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PhysicalPlanOptimizerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PhysicalPlanOptimizerTests.java @@ -7793,6 +7793,7 @@ public void testReductionPlanForAggs() { } public void testEqualsPushdownToDelegate() { + assumeFalse("disabled from bug", true); var optimized = optimizedPlan(physicalPlan(""" FROM test | WHERE job == "v" From c13ba92d682e9b20f5f123b2203334278d751488 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 22 Apr 2025 18:37:25 -0400 Subject: [PATCH 2/2] Update docs/changelog/127199.yaml --- docs/changelog/127199.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docs/changelog/127199.yaml diff --git a/docs/changelog/127199.yaml b/docs/changelog/127199.yaml new file mode 100644 index 0000000000000..e6b3710f7e97c --- /dev/null +++ b/docs/changelog/127199.yaml @@ -0,0 +1,6 @@ +pr: 127199 +summary: Disable a bugged commit +area: ES|QL +type: bug +issues: + - 127197