use of org.apache.phoenix.expression.OrExpression in project phoenix by apache.
the class ExpressionCompiler method orExpression.
private Expression orExpression(List<Expression> children) throws SQLException {
Iterator<Expression> iterator = children.iterator();
Determinism determinism = Determinism.ALWAYS;
while (iterator.hasNext()) {
Expression child = iterator.next();
if (child.getDataType() != PBoolean.INSTANCE) {
throw TypeMismatchException.newException(PBoolean.INSTANCE, child.getDataType(), child.toString());
}
if (LiteralExpression.isFalse(child)) {
iterator.remove();
}
if (LiteralExpression.isTrue(child)) {
return child;
}
determinism = determinism.combine(child.getDeterminism());
}
if (children.size() == 0) {
return LiteralExpression.newConstant(false, determinism);
}
if (children.size() == 1) {
return children.get(0);
}
return new OrExpression(children);
}
Aggregations