[fix](nereids)need do type coercion after simplify comparasion predicate (#29546)

This commit is contained in:
starocean999
2024-01-06 13:34:04 +08:00
committed by GitHub
parent cbcb81f381
commit 8908a347bc
2 changed files with 31 additions and 8 deletions

View File

@ -52,6 +52,7 @@ import org.apache.doris.nereids.types.DateType;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.DecimalV3Type;
import org.apache.doris.nereids.types.coercion.DateLikeType;
import org.apache.doris.nereids.util.TypeCoercionUtils;
import com.google.common.base.Preconditions;
@ -285,18 +286,21 @@ public class SimplifyComparisonPredicate extends AbstractExpressionRewriteRule {
return BooleanLiteral.of(false);
} else if (comparisonPredicate instanceof GreaterThan
|| comparisonPredicate instanceof LessThanEqual) {
return comparisonPredicate.withChildren(left,
convertDecimalToIntegerLikeLiteral(
literal.setScale(0, RoundingMode.FLOOR)));
return TypeCoercionUtils
.processComparisonPredicate((ComparisonPredicate) comparisonPredicate
.withChildren(left, convertDecimalToIntegerLikeLiteral(
literal.setScale(0, RoundingMode.FLOOR))));
} else if (comparisonPredicate instanceof LessThan
|| comparisonPredicate instanceof GreaterThanEqual) {
return comparisonPredicate.withChildren(left,
convertDecimalToIntegerLikeLiteral(
literal.setScale(0, RoundingMode.CEILING)));
return TypeCoercionUtils
.processComparisonPredicate((ComparisonPredicate) comparisonPredicate
.withChildren(left, convertDecimalToIntegerLikeLiteral(
literal.setScale(0, RoundingMode.CEILING))));
}
} else {
return comparisonPredicate.withChildren(left,
convertDecimalToIntegerLikeLiteral(literal));
return TypeCoercionUtils
.processComparisonPredicate((ComparisonPredicate) comparisonPredicate
.withChildren(left, convertDecimalToIntegerLikeLiteral(literal)));
}
}
return comparisonPredicate;