Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Currently, CAST will use the first keyword subfield of a text field for an expression in WHERE clause that gets translated to a painless script which will lead to an exception thrown: ``` "root_cause": [ { "type": "script_exception", "reason": "runtime error", "script_stack": [ "org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:759)", "org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:116)", "org.elasticsearch.index.query.QueryShardContext.lambda$lookup$0(QueryShardContext.java:308)", "org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:101)", "org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:98)", "java.security.AccessController.doPrivileged(Native Method)", "org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:98)", "org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)", "org.elasticsearch.xpack.sql.expression.function.scalar.whitelist.InternalSqlScriptUtils.docValue(InternalSqlScriptUtils.java:79)", "InternalSqlScriptUtils.cast(InternalSqlScriptUtils.docValue(doc,params.v0),params.v1)", " ^---- HERE" ], "script": "InternalSqlScriptUtils.cast(InternalSqlScriptUtils.docValue(doc,params.v0),params.v1)", "lang": "painless" } ], ``` Instead of allowing a painless translation using the first underlying keyword silently, which can be confusing, we detect such usage and throw\ an error early. Relates to #60178 (cherry picked from commit 7402e82)
- Loading branch information