public static Expression convertToRoundExpressionIfNeeded(PDataType fromDataType, PDataType targetDataType, List<Expression> expressions) throws SQLException {
Expression firstChildExpr = expressions.get(0);
if(fromDataType == targetDataType) {
return firstChildExpr;
} else if(fromDataType == PDataType.DECIMAL && targetDataType.isCoercibleTo(PDataType.LONG)) {
return new RoundDecimalExpression(expressions);
} else if((fromDataType == PDataType.TIMESTAMP || fromDataType == PDataType.UNSIGNED_TIMESTAMP) && targetDataType.isCoercibleTo(PDataType.DATE)) {
return RoundTimestampExpression.create(expressions);
} else if(!fromDataType.isCoercibleTo(targetDataType)) {
throw TypeMismatchException.newException(fromDataType, targetDataType, firstChildExpr.toString());
}