Skip to content

ESQL: offset in decay function can have wrong type ignoring the value type #134789

@timgrein

Description

@timgrein

Elasticsearch Version

9.2

Installed Plugins

No response

Java Version

bundled

OS Version

Darwin Kernel Version 24.3.0

Problem Description

Currently we're checking that origin and scale have a suitable type with regards to the value parameter, but we do not check this for offset. So in theory someone could specify a temporal offset for a numeric decay, which will lead to a class cast exception somewhere down in the evaluator code.

Steps to Reproduce

POST {{ES_HOST}}/_query?format=txt

{
    "query": "ROW value = 10, origin = 10, scale = 10 | EVAL score = decay(value, origin, scale, {\"offset\": \"10km\"})"
}

Error:

{
    "error": {
        "root_cause": [
            {
                "type": "class_cast_exception",
                "reason": "class org.apache.lucene.util.BytesRef cannot be cast to class java.lang.Integer (org.apache.lucene.util.BytesRef is in module [email protected] of loader 'app'; java.lang.Integer is in module java.base of loader 'bootstrap')"
            }
        ],
        "type": "class_cast_exception",
        "reason": "class org.apache.lucene.util.BytesRef cannot be cast to class java.lang.Integer (org.apache.lucene.util.BytesRef is in module [email protected] of loader 'app'; java.lang.Integer is in module java.base of loader 'bootstrap')"
    },
    "status": 500
}

Expected behavior: clear type error message that offset needs to be an integer instead of a raw class cast exception

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Labels

:Search Relevance/ES|QLSearch functionality in ES|QL:SearchOrg/RelevanceLabel for the Search (solution/org) Relevance team>bugTeam:Search - RelevanceThe Search organization Search Relevance teamTeam:Search RelevanceMeta label for the Search Relevance team in ElasticsearchTeam:SearchOrgMeta label for the Search Org (Enterprise Search)priority:normalA label for assessing bug priority to be used by ES engineers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions