Skip to content

Commit

Permalink
ESQL: extend TranslationAware to all pushable expressions (#120192) (#…
Browse files Browse the repository at this point in the history
…120475)

This expands the `TranslationAware` interface for expressions that
support translations to Lucene query and moves the implementations of
these translations from a centralised place (ExpressionTranslators) to
the respective expression classes.

`TranslationAware` has now a subinterface,
`SingleValueTranslationAware`, for expressions that need to implement
the single-value logic (`null` out on MVs). So the `SingleValueQuery`
wrapping no longer needs to be performed explicitly by the implementer.

`TranslationAware` is now part of the
`org.elasticsearch.xpack.esql.capabilities` package, together with the
other interfaces that extensions needs to implement to be used by the
core services (verifier and optimizer). To allow this, some logical
nodes have been moved from core in the ESQL proper (where also
`LucenePushdownPredicates` resides, used by `TranslationAware`).

(cherry picked from commit a867127)
  • Loading branch information
bpintea authored Jan 20, 2025
1 parent de5be24 commit f3fffc1
Show file tree
Hide file tree
Showing 91 changed files with 1,178 additions and 1,284 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/120192.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 120192
summary: Extend `TranslationAware` to all pushable expressions
area: ES|QL
type: enhancement
issues: []

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@

package org.elasticsearch.xpack.esql.core.util;

import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
import org.elasticsearch.xpack.esql.core.expression.Literal;
import org.elasticsearch.xpack.esql.core.expression.predicate.Range;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;
import org.elasticsearch.xpack.esql.core.type.EsField;
Expand All @@ -21,7 +19,6 @@
import static org.elasticsearch.test.ESTestCase.randomAlphaOfLength;
import static org.elasticsearch.test.ESTestCase.randomBoolean;
import static org.elasticsearch.test.ESTestCase.randomFrom;
import static org.elasticsearch.test.ESTestCase.randomZone;
import static org.elasticsearch.xpack.esql.core.tree.Source.EMPTY;
import static org.elasticsearch.xpack.esql.core.type.DataType.INTEGER;

Expand All @@ -44,10 +41,6 @@ public static Literal of(Source source, Object value) {
return new Literal(source, value, DataType.fromJava(value));
}

public static Range rangeOf(Expression value, Expression lower, boolean includeLower, Expression upper, boolean includeUpper) {
return new Range(EMPTY, value, lower, includeLower, upper, includeUpper, randomZone());
}

public static FieldAttribute fieldAttribute() {
return fieldAttribute(randomAlphaOfLength(10), randomFrom(DataType.types()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.elasticsearch.xpack.esql.core.expression.FoldContext;
import org.elasticsearch.xpack.esql.core.expression.Literal;
import org.elasticsearch.xpack.esql.core.expression.ReferenceAttribute;
import org.elasticsearch.xpack.esql.core.expression.predicate.Range;
import org.elasticsearch.xpack.esql.core.expression.predicate.regex.RLikePattern;
import org.elasticsearch.xpack.esql.core.expression.predicate.regex.WildcardPattern;
import org.elasticsearch.xpack.esql.core.tree.Source;
Expand All @@ -55,6 +54,7 @@
import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.RLike;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.WildcardLike;
import org.elasticsearch.xpack.esql.expression.predicate.Range;
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.Equals;
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.GreaterThan;
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.GreaterThanOrEqual;
Expand Down
Loading

0 comments on commit f3fffc1

Please sign in to comment.