[fix](Nereids) cast to boolean wrong when constant folding by be (#39019) (#39128)

pick from master #39019

not add case because be return wrong answer for this

select cast(2.0 as boolean); -- should return 1 not 2
This commit is contained in:
morrySnow
2024-08-09 04:00:21 +08:00
committed by GitHub
parent 8678fcea32
commit 08bd2baa8e

View File

@ -330,7 +330,7 @@ public class FoldConstantRuleOnBE implements ExpressionPatternRuleFactory {
} else if (type.isBooleanType()) {
int num = resultContent.getUint32ValueCount();
for (int i = 0; i < num; ++i) {
Literal literal = BooleanLiteral.of(resultContent.getUint32Value(i) == 1);
Literal literal = BooleanLiteral.of(resultContent.getUint32Value(i) != 0);
res.add(literal);
}
} else if (type.isTinyIntType()) {