pfzhan commented on code in PR #3326:
URL: https://github.com/apache/calcite/pull/3326#discussion_r1280065022
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java:
##########
@@ -838,6 +848,13 @@ public static Expression translateLiteral(
return Expressions.constant(value2, javaClass);
}
+ private static MethodCallExpression adjustDecimalScale(int scale,
+ Expression expression) {
+ assert expression.getType() == BigDecimal.class;
+ return Expressions.call(expression,
BuiltInMethod.BIG_DECIMAL_SET_SCALE.method,
+ Expressions.constant(scale),
Expressions.constant(RoundingMode.HALF_UP));
Review Comment:
I've been thinking about this point for quite a while,
`RoundingMode.HALF_UP` might not be the best, maybe `RoundingMode.HALF_EVEN`
would be better, but I'm not really sure, so I refer to the
`org.apache.calcite.util.NumberUtil#rescaleBigDecimal` to keep the behavior
consistent with the original. If we plan to tweak the use of `RoundingMode`, I
think we'll probably need to look at all the places where it is already being
used and refer to more DBMSs to make the tradeoffs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]