Skip to content

Commit ec60f5f

Browse files
committed
Add test for colons in FROM, ENRICH and MATCH
1 parent 71328d6 commit ec60f5f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.elasticsearch.xpack.esql.expression.function.aggregate.Count;
3232
import org.elasticsearch.xpack.esql.expression.function.aggregate.Max;
3333
import org.elasticsearch.xpack.esql.expression.function.aggregate.Min;
34+
import org.elasticsearch.xpack.esql.expression.function.fulltext.Match;
3435
import org.elasticsearch.xpack.esql.index.EsIndex;
3536
import org.elasticsearch.xpack.esql.index.IndexResolution;
3637
import org.elasticsearch.xpack.esql.parser.ParsingException;
@@ -2310,6 +2311,27 @@ public void testInvalidNamedParamsForIdentifierPatterns() {
23102311
);
23112312
}
23122313

2314+
public void testFromEnrichAndMatchColonUsage() {
2315+
assumeTrue("Match operator is available just for snapshots", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
2316+
2317+
LogicalPlan plan = analyze("""
2318+
from *:test
2319+
| EVAL x = to_string(languages)
2320+
| ENRICH _any:languages ON x
2321+
| WHERE first_name: "Anna"
2322+
""", "mapping-default.json");
2323+
var limit = as(plan, Limit.class);
2324+
var filter = as(limit.child(), Filter.class);
2325+
var match = as(filter.condition(), Match.class);
2326+
var enrich = as(filter.child(), Enrich.class);
2327+
assertEquals(enrich.mode(), Enrich.Mode.ANY);
2328+
assertEquals(enrich.policy().getMatchField(), "language_code");
2329+
var eval = as(enrich.child(), Eval.class);
2330+
var esRelation = as(eval.child(), EsRelation.class);
2331+
assertEquals(esRelation.index().name(), "test");
2332+
2333+
}
2334+
23132335
private void verifyUnsupported(String query, String errorMessage) {
23142336
verifyUnsupported(query, errorMessage, "mapping-multi-field-variation.json");
23152337
}

0 commit comments

Comments
 (0)