Github user DmytroShkvyra commented on a diff in the pull request:
https://github.com/apache/flink/pull/2870#discussion_r103734557
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/codegen/calls/ScalarOperators.scala
---
@@ -1002,12 +1068,17 @@ object ScalarOperators {
val resultTypeTerm = primitiveTypeTermForTypeInfo(resultType)
// no casting necessary
if (operandType == resultType) {
- (operandTerm) => s"$operandTerm"
+ if (isDecimal(operandType)) {
+ (operandTerm) => s"$operandTerm.stripTrailingZeros()"
--- End diff --
@twalthr I continue work of @NickolayVasilishin and found In
5WD-01-Framework-2003-09.pdf (SQL:2003 standard) following text:
> There are two classes of numeric type: exact numeric, which includes
integer types and types with specified
precision and scale; and approximate numeric, which is essentially floating
point, and for which a precision
may optionally be specified.
Every number has a precision (number of digits), and exact numeric types
also have a scale (digits after the
radix point). Arithmetic operations may be performed on operands of
different or the same numeric type, and
the result is of a numeric type that depends only on the numeric type of
the operands. If the result cannot be
represented exactly in the result type, then whether it is rounded or
truncated is implementation-defined. An
exception condition is raised if the result is outside the range of numeric
values of the result type, or if the
arithmetic operation is not defined for the operands.
<BigDecimal> can has different <MathContext> and different scale, precision
and rounding modes.
I think, in case of <BigDecimal> we have to strip trailing zeros to avoid
possible problem with parsing of <BigDecimal> value from strings
BTW, standard do not says that 2.00 can be unequal to 2
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---