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] Class cast exception mixing division and comparison #108388

Closed
not-napoleon opened this issue May 7, 2024 · 1 comment · Fixed by #109256
Closed

[ESQL] Class cast exception mixing division and comparison #108388

not-napoleon opened this issue May 7, 2024 · 1 comment · Fixed by #109256
Assignees
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@not-napoleon
Copy link
Member

Elasticsearch Version

main

Installed Plugins

No response

Java Version

bundled

OS Version

n/a

Problem Description

FROM test | EVAL x = double / 2 > 4 results in a ClassCastException:

        "reason": "class org.elasticsearch.compute.data.DoubleVectorBlock cannot be cast to class org.elasticsearch.compute.data.IntBlock (org.elasticsearch.compute.data.DoubleVectorBlock and org.elasticsearch.compute.data.IntBlock are in unnamed module of loader java.net.FactoryURLClassLoader @45e11627)"

This seems to only happen when both division and comparison are involved. Neither FROM test | EVAL x = double / 2 and FROM test | EVAL x = double > 4 trigger the error.

Steps to Reproduce

PUT http://localhost:9200/test
content-type: application/json

{
  "mappings": {
    "properties": {
        "float": {"type": "float"},
        "int": {"type": "integer"},
        "double": {"type": "double"}
    }
  }
}


POST http://localhost:9200/_query?format=txt
content-type: application/json

{
  "version": "2024.04.01",
  "query": "FROM test | EVAL x = double / 2 > 4" 
}

Logs (if relevant)

No response

@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 May 7, 2024
not-napoleon added a commit that referenced this issue Jun 3, 2024
This pulls the SimplifyComparisonArithmetics optimization into ESQL proper, from core, and in doing so resolves two of the issues we uncovered with that optimization.

Rather than moving this into a sub-class of OptimzierRules, I've opted to create a new package optimizer.rules, and put this as a top level class there. I have another PR open that migrates a bunch of other rules into OptimizerRules, and that's in general an area of the code that's being touched a lot lately. Having top level classes in a package, rather than sub-classes in a single class file, will create fewer conflicts while working on things that are actually unrelated in this type of situation.

Although this is a bugfix, I did not mark it for backporting to 8.14. To my knowledge, no users have reported the associated bugs (we found them through migrating tests), and this fix depends on tests and refactorings that were not backported to 8.14. It would be possible to write an 8.14 version of this, but IMHO it's easier to do as a fresh ticket than as a backport and conflict resolution process. If we think that's important, I'm happy to do so, but at the moment I think fixing it for 8.15 is fine.

Note that this is a re-application of the changes in #108200 after we did other refactoring, which that was closed to enable.

Resolves #108388
Resolves #108743
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
2 participants