use of com.pingcap.tikv.expression.ComparisonBinaryExpression.NormalizedPredicate in project tispark by pingcap.
the class PartAndFilterExprRewriter method visit.
@Override
public Expression visit(ComparisonBinaryExpression node, Void context) {
NormalizedPredicate predicate = node.normalize();
// predicate maybe null if node's left or right does not have a column ref or a constant.
if (predicate != null) {
if (!columnRefs.contains(predicate.getColumnRef())) {
return node;
}
// we only support year for now.
if (isYear()) {
FuncCallExpr year = new FuncCallExpr(predicate.getValue(), Type.YEAR);
Constant newLiteral = year.eval(predicate.getValue());
return new ComparisonBinaryExpression(node.getComparisonType(), node.getLeft(), newLiteral);
} else if (isColumnRef()) {
return node;
}
unsupportedPartFnFound = true;
return null;
}
// when we find a node in form like [year(y) < 1995], we need rewrite the left child.
Expression left = node.getLeft().accept(this, null);
Expression right = node.getRight().accept(this, null);
return new ComparisonBinaryExpression(node.getComparisonType(), left, right);
}
use of com.pingcap.tikv.expression.ComparisonBinaryExpression.NormalizedPredicate in project tispark by pingcap.
the class PrunedPartitionBuilder method visit.
@Override
protected RangeSet<TypedKey> visit(ComparisonBinaryExpression node, Void context) {
NormalizedPredicate predicate = node.normalize();
// which indicates it cannot be pruned such as a > b + 1
if (predicate == null)
return TreeRangeSet.<TypedKey>create().complement();
if (!partExprColRefs.contains(predicate.getColumnRef()))
return TreeRangeSet.<TypedKey>create().complement();
TypedKey literal;
literal = predicate.getTypedLiteral(-1);
return visitComparisonBinaryExpr(node, context, literal, false);
}
Aggregations