Skip to content

We created a shared data structure (e.g., a map of supported evaluato… #127097

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BinhMike
Copy link

@BinhMike BinhMike commented Apr 20, 2025

In the existing implementation of Greatest and Least, the resolveType method only checks whether all input data types are the same. However, the toEvaluator function separately maintains a list of types it can handle. This mismatch leads to cases where resolveType succeeds, but toEvaluator fails with an illegal type exception.
Implementation Summary: We created a shared data structure (e.g., a map of supported evaluators by data type) that is referenced consistently in both resolveType and toEvaluator. This approach mirrors the strategy used in binary comparison operators, ensuring type validation is unified. The implementation required modifying the ESQL expression evaluator logic and testing the affected classes for data type coverage.

…rs by data type) that is referenced consistently in both resolveType and toEvaluator
Copy link

❌ Author of the following commits did not sign a Contributor Agreement:
765e633

Please, read and sign the above mentioned agreement if you want to contribute to this project

@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label v9.1.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Apr 20, 2025
@gbanasiak gbanasiak added the :Analytics/ES|QL AKA ESQL label Apr 28, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Apr 28, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine elasticsearchmachine removed the needs:triage Requires assignment of a team area label label Apr 28, 2025
Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

This mismatch leads to cases where resolveType succeeds, but toEvaluator fails with an illegal type exception.

Part of adding support for a type is adding evaluators for it. Everything else that trickles through is a defect. Adding a generic evaluator high in the class hierarchy isn't possible.
The existing implementation is correct.

This proposed change isn't correct and lacks to showcase the error in tests it corrects -- you'll need to add tests for nearly every proposed change. You may refer to similar PRs and code base to learn more about which tests would be necessary.

You'll want to give your PRs a correct title too, to summarise their intention.

Copy link
Contributor

Choose a reason for hiding this comment

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

These are cosmetic changes unrelated to the proposed change.

Copy link
Contributor

Choose a reason for hiding this comment

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

The changes here are incorrect, the evaluators are expressions-specific.
Also, the style doesn't conform to project's -- please refer to https://github.com/elastic/elasticsearch/blob/main/CONTRIBUTING.md

Copy link
Contributor

Choose a reason for hiding this comment

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

These are changes that aren't related to the proposed change.
Also, the {} markers are later handled by LoggerMessageFormat#format, so there's no error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants