Skip to content

SQL: Negated (NOT) LIKE expression doesn't work #36584

@astefan

Description

@astefan

This one works just fine: select * from test_emp where first_name like 'A%';.
While these two do not:

select * from test_emp where first_name not like 'A%';
select * from test_emp where NOT (first_name like 'A%');
sql> select * from test_emp where NOT (first_name like 'A%');
Server error [Server encountered an error [Cannot evaluate script for expression LikePattern[A%, ]]. [SqlIllegalArgumentException[Cannot evaluate script for expression LikePattern[A%, ]]
        at org.elasticsearch.xpack.sql.expression.gen.script.ScriptWeaver.asScript(ScriptWeaver.java:44)
        at org.elasticsearch.xpack.sql.expression.function.scalar.BinaryScalarFunction.asScript(BinaryScalarFunction.java:53)
        at org.elasticsearch.xpack.sql.expression.function.scalar.ScalarFunction.toAttribute(ScalarFunction.java:38)
        at org.elasticsearch.xpack.sql.expression.function.scalar.ScalarFunction.toAttribute(ScalarFunction.java:23)
        at org.elasticsearch.xpack.sql.expression.Expressions.attribute(Expressions.java:122)
        at org.elasticsearch.xpack.sql.expression.gen.script.ScriptWeaver.asScript(ScriptWeaver.java:32)
        at org.elasticsearch.xpack.sql.expression.function.scalar.UnaryScalarFunction.asScript(UnaryScalarFunction.java:62)
        at org.elasticsearch.xpack.sql.planner.QueryTranslator$ExpressionTranslator.handleQuery(QueryTranslator.java:827)

Initially reported here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions