|
18 | 18 | import org.elasticsearch.xpack.esql.common.Failure; |
19 | 19 | import org.elasticsearch.xpack.esql.common.Failures; |
20 | 20 | import org.elasticsearch.xpack.esql.core.InvalidArgumentException; |
21 | | -import org.elasticsearch.xpack.esql.core.expression.EntryExpression; |
22 | 21 | import org.elasticsearch.xpack.esql.core.expression.Expression; |
23 | 22 | import org.elasticsearch.xpack.esql.core.expression.FieldAttribute; |
24 | 23 | import org.elasticsearch.xpack.esql.core.expression.FoldContext; |
25 | | -import org.elasticsearch.xpack.esql.core.expression.Literal; |
26 | 24 | import org.elasticsearch.xpack.esql.core.expression.MapExpression; |
27 | | -import org.elasticsearch.xpack.esql.core.expression.TypeResolutions; |
28 | 25 | import org.elasticsearch.xpack.esql.core.querydsl.query.Query; |
29 | 26 | import org.elasticsearch.xpack.esql.core.tree.NodeInfo; |
30 | 27 | import org.elasticsearch.xpack.esql.core.tree.Source; |
31 | 28 | import org.elasticsearch.xpack.esql.core.type.DataType; |
32 | | -import org.elasticsearch.xpack.esql.core.type.DataTypeConverter; |
33 | 29 | import org.elasticsearch.xpack.esql.core.type.MultiTypeEsField; |
34 | 30 | import org.elasticsearch.xpack.esql.core.util.Check; |
35 | 31 | import org.elasticsearch.xpack.esql.core.util.NumericUtils; |
|
56 | 52 | import java.util.function.BiConsumer; |
57 | 53 |
|
58 | 54 | import static java.util.Map.entry; |
59 | | -import static org.elasticsearch.common.logging.LoggerMessageFormat.format; |
60 | 55 | import static org.elasticsearch.index.query.AbstractQueryBuilder.BOOST_FIELD; |
61 | 56 | import static org.elasticsearch.index.query.MatchQueryBuilder.ANALYZER_FIELD; |
62 | 57 | import static org.elasticsearch.index.query.MatchQueryBuilder.FUZZY_REWRITE_FIELD; |
|
71 | 66 | import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.FIRST; |
72 | 67 | import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND; |
73 | 68 | import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.THIRD; |
74 | | -import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isFoldable; |
75 | 69 | import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isMapExpression; |
76 | 70 | import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNotNull; |
77 | 71 | import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNotNullAndFoldable; |
@@ -374,41 +368,6 @@ private TypeResolution resolveOptions() { |
374 | 368 | return TypeResolution.TYPE_RESOLVED; |
375 | 369 | } |
376 | 370 |
|
377 | | - public static void populateOptionsMap( |
378 | | - final MapExpression options, |
379 | | - final Map<String, Object> optionsMap, |
380 | | - final TypeResolutions.ParamOrdinal paramOrdinal, |
381 | | - final String sourceText, |
382 | | - final Map<String, DataType> allowedOptions |
383 | | - ) throws InvalidArgumentException { |
384 | | - for (EntryExpression entry : options.entryExpressions()) { |
385 | | - Expression optionExpr = entry.key(); |
386 | | - Expression valueExpr = entry.value(); |
387 | | - TypeResolution resolution = isFoldable(optionExpr, sourceText, paramOrdinal).and( |
388 | | - isFoldable(valueExpr, sourceText, paramOrdinal) |
389 | | - ); |
390 | | - if (resolution.unresolved()) { |
391 | | - throw new InvalidArgumentException(resolution.message()); |
392 | | - } |
393 | | - Object optionExprLiteral = ((Literal) optionExpr).value(); |
394 | | - Object valueExprLiteral = ((Literal) valueExpr).value(); |
395 | | - String optionName = optionExprLiteral instanceof BytesRef br ? br.utf8ToString() : optionExprLiteral.toString(); |
396 | | - String optionValue = valueExprLiteral instanceof BytesRef br ? br.utf8ToString() : valueExprLiteral.toString(); |
397 | | - // validate the optionExpr is supported |
398 | | - DataType dataType = allowedOptions.get(optionName); |
399 | | - if (dataType == null) { |
400 | | - throw new InvalidArgumentException( |
401 | | - format(null, "Invalid option [{}] in [{}], expected one of {}", optionName, sourceText, allowedOptions.keySet()) |
402 | | - ); |
403 | | - } |
404 | | - try { |
405 | | - optionsMap.put(optionName, DataTypeConverter.convert(optionValue, dataType)); |
406 | | - } catch (InvalidArgumentException e) { |
407 | | - throw new InvalidArgumentException(format(null, "Invalid option [{}] in [{}], {}", optionName, sourceText, e.getMessage())); |
408 | | - } |
409 | | - } |
410 | | - } |
411 | | - |
412 | 371 | private Map<String, Object> matchQueryOptions() throws InvalidArgumentException { |
413 | 372 | if (options() == null) { |
414 | 373 | return Map.of(LENIENT_FIELD.getPreferredName(), true); |
|
0 commit comments