Skip to content

Commit 373c8eb

Browse files
committed
Fix merge errors
1 parent 553fb02 commit 373c8eb

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.elasticsearch.xpack.esql.core.InvalidArgumentException;
2222
import org.elasticsearch.xpack.esql.core.expression.EntryExpression;
2323
import org.elasticsearch.xpack.esql.core.expression.Expression;
24+
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
2425
import org.elasticsearch.xpack.esql.core.expression.FoldContext;
2526
import org.elasticsearch.xpack.esql.core.expression.Literal;
2627
import org.elasticsearch.xpack.esql.core.expression.MapExpression;
@@ -31,7 +32,9 @@
3132
import org.elasticsearch.xpack.esql.core.tree.Source;
3233
import org.elasticsearch.xpack.esql.core.type.DataType;
3334
import org.elasticsearch.xpack.esql.core.type.DataTypeConverter;
35+
import org.elasticsearch.xpack.esql.core.type.MultiTypeEsField;
3436
import org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper;
37+
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.AbstractConvertFunction;
3538
import org.elasticsearch.xpack.esql.expression.predicate.logical.BinaryLogic;
3639
import org.elasticsearch.xpack.esql.expression.predicate.logical.Not;
3740
import org.elasticsearch.xpack.esql.optimizer.rules.physical.local.LucenePushdownPredicates;
@@ -57,6 +60,8 @@
5760
import static org.elasticsearch.xpack.esql.common.Failure.fail;
5861
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
5962
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isFoldable;
63+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isMapExpression;
64+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNotNull;
6065
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNotNullAndFoldable;
6166
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isString;
6267

@@ -365,4 +370,47 @@ protected static void populateOptionsMap(
365370
}
366371
}
367372
}
373+
374+
protected TypeResolution resolveOptions(Expression options, TypeResolutions.ParamOrdinal paramOrdinal) {
375+
if (options != null) {
376+
TypeResolution resolution = isNotNull(options, sourceText(), paramOrdinal);
377+
if (resolution.unresolved()) {
378+
return resolution;
379+
}
380+
// MapExpression does not have a DataType associated with it
381+
resolution = isMapExpression(options, sourceText(), paramOrdinal);
382+
if (resolution.unresolved()) {
383+
return resolution;
384+
}
385+
386+
try {
387+
resolvedOptions();
388+
} catch (InvalidArgumentException e) {
389+
return new TypeResolution(e.getMessage());
390+
}
391+
}
392+
return TypeResolution.TYPE_RESOLVED;
393+
}
394+
395+
protected Map<String, Object> resolvedOptions() throws InvalidArgumentException {
396+
return Map.of();
397+
}
398+
399+
public static String getNameFromFieldAttribute(FieldAttribute fieldAttribute) {
400+
String fieldName = fieldAttribute.name();
401+
if (fieldAttribute.field() instanceof MultiTypeEsField multiTypeEsField) {
402+
// If we have multiple field types, we allow the query to be done, but getting the underlying field name
403+
fieldName = multiTypeEsField.getName();
404+
}
405+
return fieldName;
406+
}
407+
408+
public static FieldAttribute fieldAsFieldAttribute(Expression field) {
409+
Expression fieldExpression = field;
410+
// Field may be converted to other data type (field_name :: data_type), so we need to check the original field
411+
if (fieldExpression instanceof AbstractConvertFunction convertFunction) {
412+
fieldExpression = convertFunction.field();
413+
}
414+
return fieldExpression instanceof FieldAttribute fieldAttribute ? fieldAttribute : null;
415+
}
368416
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
2727
import org.elasticsearch.xpack.esql.core.tree.Source;
2828
import org.elasticsearch.xpack.esql.core.type.DataType;
29+
import org.elasticsearch.xpack.esql.core.type.MultiTypeEsField;
2930
import org.elasticsearch.xpack.esql.core.util.Check;
3031
import org.elasticsearch.xpack.esql.core.util.NumericUtils;
3132
import org.elasticsearch.xpack.esql.expression.function.Example;

0 commit comments

Comments
 (0)