mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 13:08:29 +00:00
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 7402e8267ba564e52dc672c25b262824b6048b40)
Elastic License Functionality
This directory tree contains files subject to the Elastic License. The files subject to the Elastic License are grouped in this directory to clearly separate them from files licensed under the Apache License 2.0.