return getFloorExpression(children);
}
public static Expression getFloorExpression(List<Expression> children) throws SQLException {
final Expression firstChild = children.get(0);
final PDataType firstChildDataType = firstChild.getDataType();
//FLOOR on timestamp doesn't really care about the nanos part i.e. it just sets it to zero.
//Which is exactly what FloorDateExpression does too.
if(firstChildDataType.isCoercibleTo(PDataType.TIMESTAMP)) {
return FloorDateExpression.create(children);
} else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) {
return FloorDecimalExpression.create(children);
} else {
throw TypeMismatchException.newException(firstChildDataType, "1");
}
}