}
}
@Override
public Datum eval(Schema schema, Tuple tuple) {
Datum lhs = leftExpr.eval(schema, tuple);
Datum rhs = rightExpr.eval(schema, tuple);
switch(type) {
case AND:
return lhs.and(rhs);
case OR:
return lhs.or(rhs);
case EQUAL:
return lhs.equalsTo(rhs);
case NOT_EQUAL:
return lhs.notEqualsTo(rhs);
case LTH:
return lhs.lessThan(rhs);
case LEQ:
return lhs.lessThanEqual(rhs);
case GTH:
return lhs.greaterThan(rhs);
case GEQ:
return lhs.greaterThanEqual(rhs);
case PLUS:
return lhs.plus(rhs);
case MINUS:
return lhs.minus(rhs);
case MULTIPLY:
return lhs.multiply(rhs);
case DIVIDE:
return lhs.divide(rhs);
case MODULAR:
return lhs.modular(rhs);
case CONCATENATE:
if (lhs.type() == Type.NULL_TYPE || rhs.type() == Type.NULL_TYPE) {
return NullDatum.get();
}
return DatumFactory.createText(lhs.asChars() + rhs.asChars());
default:
throw new InvalidEvalException("We does not support " + type + " expression yet");
}
}