Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
SqlStdOperatorTable.NOT_LIKE's implementor defined in RexImpTable is currently the same as LIKE (i.e. NOT_LIKE performs the same operation as LIKE):
... final MethodImplementor likeImplementor = new MethodImplementor(BuiltInMethod.LIKE.method, NullPolicy.STRICT, false); map.put(LIKE, likeImplementor); map.put(NOT_LIKE, likeImplementor);
It should be:
... map.put(LIKE, likeImplementor); map.put(NOT_LIKE, NotImplementor.of(likeImplementor));
Luckily, SQL queries seem to not suffer the consequences because StandardConvertletTable expands x NOT LIKE y into NOT (x LIKE y), so the issue is avoided:
// Expand "x NOT LIKE y" into "NOT (x LIKE y)"
registerOp(SqlStdOperatorTable.NOT_LIKE,
(cx, call) -> cx.convertExpression(
SqlStdOperatorTable.NOT.createCall(SqlParserPos.ZERO,
SqlStdOperatorTable.LIKE.createCall(SqlParserPos.ZERO,
call.getOperandList()))));
However, creating a plan via RelBuilder using SqlStdOperatorTable.NOT_LIKE will lead to incorrect results.