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

ES|QL: ReplaceMissingFieldWithNull could lead to ClassCastException #110150

Open
luigidellaquila opened this issue Jun 25, 2024 · 2 comments
Open
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@luigidellaquila
Copy link
Contributor

ReplaceMissingFieldWithNull local logical optimization rule replaces expressions with a NULL Literal when a field is not mapped on local node.

This is dangerous because a Literal could not match the type of the expressions that are being replaced (eg. if the command expects a NamedExpression like in this case), and it can trigger a ClassCastException.

With current feature set this optimization is safe, but we could miss the problem when we add new commands.

Notice that this optimization triggers a few other downstream optimizations that can be quite important, see LocalLogicalPlanOptimizerTests.testMissingField*

@elasticsearchmachine
Copy link
Collaborator

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

@alex-spies
Copy link
Contributor

IMO this is a bug, so I marked this accordingly. This piece of code performs a wild, unchecked cast without any safeguards; this is bound to break again in the future, especially since we plan to add new logical plan nodes (and evolve existing ones).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

3 participants