Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BooleanType;
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.util.ExpressionUtils;

import com.google.common.collect.BoundType;
Expand Down Expand Up @@ -113,8 +114,10 @@ private ValueDesc buildRange(ExpressionRewriteContext context, ComparisonPredica
if (right.isNullLiteral()) {
return new UnknownValue(context, predicate);
}
// only handle `NumericType` and `DateLikeType`
if (right.isLiteral() && (right.getDataType().isNumericType() || right.getDataType().isDateLikeType())) {
// only handle `NumericType` and `DateLikeType` and `StringLikeType`
DataType rightDataType = right.getDataType();
if (right.isLiteral() && (rightDataType.isNumericType() || rightDataType.isDateLikeType()
|| rightDataType.isStringLikeType())) {
return ValueDesc.range(context, predicate);
}
return new UnknownValue(context, predicate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ public void testSimplify() {
assertRewrite("(TA + TC > 3 and TA + TC < 1) or TB < 5", "((TA + TC) is null and null) OR TB < 5");

assertRewrite("(TA + TC > 3 OR TA < 1) AND TB = 2) AND IA =1", "(TA + TC > 3 OR TA < 1) AND TB = 2) AND IA =1");
assertRewrite("SA = '20250101' and SA < '20200101'", "SA is null and null");
assertRewrite("SA > '20250101' and SA > '20260110'", "SA > '20260110'");

}

Expand Down