Skip to content

Commit 9ebdda2

Browse files
committed
Fix some tests
1 parent e0ae889 commit 9ebdda2

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/FullTextFunction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,14 +396,14 @@ protected static void populateOptionsMap(
396396
}
397397
}
398398

399-
protected TypeResolution resolveOptions(Expression options) {
399+
protected TypeResolution resolveOptions(Expression options, TypeResolutions.ParamOrdinal paramOrdinal) {
400400
if (options != null) {
401-
TypeResolution resolution = isNotNull(options, sourceText(), THIRD);
401+
TypeResolution resolution = isNotNull(options, sourceText(), paramOrdinal);
402402
if (resolution.unresolved()) {
403403
return resolution;
404404
}
405405
// MapExpression does not have a DataType associated with it
406-
resolution = isMapExpression(options, sourceText(), THIRD);
406+
resolution = isMapExpression(options, sourceText(), paramOrdinal);
407407
if (resolution.unresolved()) {
408408
return resolution;
409409
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/Match.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import static org.elasticsearch.index.query.MatchQueryBuilder.ZERO_TERMS_QUERY_FIELD;
6464
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.FIRST;
6565
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND;
66+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.THIRD;
6667
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNotNull;
6768
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNotNullAndFoldable;
6869
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isType;
@@ -299,7 +300,7 @@ public final void writeTo(StreamOutput out) throws IOException {
299300

300301
@Override
301302
protected TypeResolution resolveParams() {
302-
return resolveField().and(resolveQuery()).and(resolveOptions(options())).and(checkParamCompatibility());
303+
return resolveField().and(resolveQuery()).and(resolveOptions(options(), THIRD)).and(checkParamCompatibility());
303304
}
304305

305306
private TypeResolution resolveField() {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/MatchPhrase.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import static org.elasticsearch.index.query.MatchQueryBuilder.ANALYZER_FIELD;
5454
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.FIRST;
5555
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND;
56+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.THIRD;
5657
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNotNull;
5758
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNotNullAndFoldable;
5859
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isType;
@@ -176,6 +177,11 @@ public String getWriteableName() {
176177
return ENTRY.name;
177178
}
178179

180+
@Override
181+
public String functionName() {
182+
return ENTRY.name;
183+
}
184+
179185
private static MatchPhrase readFrom(StreamInput in) throws IOException {
180186
Source source = Source.readFrom((PlanStreamInput) in);
181187
Expression field = in.readNamedWriteable(Expression.class);
@@ -195,7 +201,7 @@ public final void writeTo(StreamOutput out) throws IOException {
195201

196202
@Override
197203
protected TypeResolution resolveParams() {
198-
return resolveField().and(resolveQuery()).and(resolveOptions(options())).and(checkParamCompatibility());
204+
return resolveField().and(resolveQuery()).and(resolveOptions(options(), THIRD)).and(checkParamCompatibility());
199205
}
200206

201207
private TypeResolution resolveField() {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/QueryString.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ protected Map<String, Object> resolvedOptions() {
333333

334334
@Override
335335
protected TypeResolution resolveParams() {
336-
return resolveQuery().and(resolveOptions(options()));
336+
return resolveQuery().and(resolveOptions(options(), SECOND));
337337
}
338338

339339
@Override

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,9 +1217,9 @@ public void testMatchInsideEval() throws Exception {
12171217

12181218
public void testMatchPhraseInsideEval() throws Exception {
12191219
assertEquals(
1220-
"1:36: [:] operator is only supported in WHERE and STATS commands\n"
1221-
+ "line 1:36: [:] operator cannot operate on [title], which is not a field from an index mapping",
1222-
error("row title = \"brown fox\" | eval x = match_phrase(title:\"fox\") ")
1220+
"1:36: [MatchPhrase] function is only supported in WHERE and STATS commands\n"
1221+
+ "line 1:49: [MatchPhrase] function cannot operate on [title], which is not a field from an index mapping",
1222+
error("row title = \"brown fox\" | eval x = match_phrase(title, \"brown fox\") ")
12231223
);
12241224
}
12251225

@@ -1261,11 +1261,11 @@ public void testMatchWithNonIndexedColumnCurrentlyUnsupported() {
12611261

12621262
public void testMatchPhraseWithNonIndexedColumnCurrentlyUnsupported() {
12631263
assertEquals(
1264-
"1:67: [MATCH_PHRASE] function cannot operate on [initial], which is not a field from an index mapping",
1264+
"1:74: [MatchPhrase] function cannot operate on [initial], which is not a field from an index mapping",
12651265
error("from test | eval initial = substring(first_name, 1) | where match_phrase(initial, \"A\")")
12661266
);
12671267
assertEquals(
1268-
"1:67: [MATCH_PHRASE] function cannot operate on [text], which is not a field from an index mapping",
1268+
"1:74: [MatchPhrase] function cannot operate on [text], which is not a field from an index mapping",
12691269
error("from test | eval text=concat(first_name, last_name) | where match_phrase(text, \"cat\")")
12701270
);
12711271
}
@@ -1279,7 +1279,7 @@ public void testMatchFunctionIsNotNullable() {
12791279

12801280
public void testMatchPhraseFunctionIsNotNullable() {
12811281
assertEquals(
1282-
"1:48: [MATCH_PHRASE] function cannot operate on [text::keyword], which is not a field from an index mapping",
1282+
"1:55: [MatchPhrase] function cannot operate on [text::keyword], which is not a field from an index mapping",
12831283
error("row n = null | eval text = n + 5 | where match_phrase(text::keyword, \"Anna\")")
12841284
);
12851285
}

0 commit comments

Comments
 (0)