[fix](Nereids) should cast NOT's child to boolean when analyze (#29433)

This commit is contained in:
morrySnow
2024-01-05 11:20:39 +08:00
committed by GitHub
parent 8c40f04f2b
commit baec2657dd

View File

@ -270,12 +270,7 @@ public class FunctionBinder extends AbstractExpressionRewriteRule {
@Override
public Expression visitNot(Not not, ExpressionRewriteContext context) {
Expression child = not.child().accept(this, context);
if (!child.getDataType().isBooleanType() && !child.getDataType().isNullType()) {
throw new AnalysisException(String.format(
"Operand '%s' part of predicate " + "'%s' should return type 'BOOLEAN' but "
+ "returns type '%s'.",
child.toSql(), not.toSql(), child.getDataType()));
}
child = TypeCoercionUtils.castIfNotSameType(child, BooleanType.INSTANCE);
return not.withChildren(child);
}