From ec9beec5493ff5a80a75a64da7ab919817268f46 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 24 Mar 2025 11:02:23 -0400 Subject: [PATCH] ESQL: Document warnings behavior in CsvTests (#125441) The `CsvTests` has a slight difference regarding warnings from real Elasticsearch indices and this is worth documenting. I've also added an explanation to `SingleValueMatchQuery` that explains *exactly* when it makes a warning because it's not *exactly* the same as when the compute engine would make a warning. The resulting documents are the same - but the warnings are not. --- .../querydsl/query/SingleValueMatchQuery.java | 12 +++++++++++- .../java/org/elasticsearch/xpack/esql/CsvTests.java | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/querydsl/query/SingleValueMatchQuery.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/querydsl/query/SingleValueMatchQuery.java index af5a4f03f32f7..e79b82c872da5 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/querydsl/query/SingleValueMatchQuery.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/querydsl/query/SingleValueMatchQuery.java @@ -37,7 +37,17 @@ import java.util.Objects; /** - * Finds all fields with a single-value. If a field has a multi-value, it emits a {@link Warnings}. + * Finds all fields with a single-value. If a field has a multi-value, it emits + * a {@link Warnings warning}. + *

+ * Warnings are only emitted if the {@link TwoPhaseIterator#matches}. Meaning that, + * if the other query skips the doc either because the index doesn't match or because it's + * {@link TwoPhaseIterator#matches} doesn't match, then we won't log warnings. So it's + * most safe to say that this will emit a warning if the document would have + * matched but for having a multivalued field. If the document doesn't match but + * "almost" matches in some fairly lucene-specific ways then it *might* emit + * a warning. + *

*/ public final class SingleValueMatchQuery extends Query { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java index ccbf9e984647e..baf8b0597f762 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java @@ -30,6 +30,7 @@ import org.elasticsearch.compute.operator.DriverRunner; import org.elasticsearch.compute.operator.exchange.ExchangeSinkHandler; import org.elasticsearch.compute.operator.exchange.ExchangeSourceHandler; +import org.elasticsearch.compute.querydsl.query.SingleValueMatchQuery; import org.elasticsearch.core.Releasables; import org.elasticsearch.core.Tuple; import org.elasticsearch.index.IndexMode; @@ -153,6 +154,17 @@ * it’s creating its own Source physical operator, aggregation operator (just a tiny bit of it) and field extract operator. *

* To log the results logResults() should return "true". + *

+ * This test never pushes to Lucene because there isn't a Lucene index to push to. It always runs everything in + * the compute engine. This yields the same results modulo a few things: + *

*/ // @TestLogging(value = "org.elasticsearch.xpack.esql:TRACE,org.elasticsearch.compute:TRACE", reason = "debug") public class CsvTests extends ESTestCase {