Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESQL: extend TranslationAware to all pushable expressions #120192

Merged
merged 10 commits into from
Jan 17, 2025

Conversation

bpintea
Copy link
Contributor

@bpintea bpintea commented Jan 15, 2025

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).

@bpintea bpintea added >enhancement auto-backport Automatically create backport pull requests when merged :Analytics/ES|QL AKA ESQL v9.0.0 v8.18.0 labels Jan 15, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @bpintea, I've created a changelog YAML for you.

@bpintea bpintea marked this pull request as ready for review January 16, 2025 08:02
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jan 16, 2025
Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great - thanks!
👍

protected ExpressionTranslator<Kql> translator() {
return new EsqlExpressionTranslators.KqlFunctionTranslator();
protected Query translate(TranslatorHandler handler) {
return new KqlQuery(source(), (String) queryAsObject());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Objects.toString(queryAsObject())

/**
* Subinterface for expressions that can only process single values (and null out on MVs).
*/
interface SingleValue extends TranslationAware {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SingleValueTranslationAware

@bpintea bpintea added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Jan 17, 2025
Copy link
Contributor

@luigidellaquila luigidellaquila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ❤️

@bpintea
Copy link
Contributor Author

bpintea commented Jan 17, 2025

Thanks Costin, Luigi.

@elasticsearchmachine elasticsearchmachine merged commit a867127 into elastic:main Jan 17, 2025
16 checks passed
@bpintea bpintea deleted the enh/translation_aware branch January 17, 2025 09:41
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 120192

bpintea added a commit to bpintea/elasticsearch that referenced this pull request Jan 20, 2025
…0192)

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)
elasticsearchmachine pushed a commit that referenced this pull request Jan 20, 2025
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants