DonnyZone commented on a change in pull request #1862: [CALCITE-3864] Add Implementation for SqlLibraryOperators.CONCAT_FUNCTION in SqlFunctions and correct the return type inference of SqlLibraryOperators.CONCAT_FUNCTION URL: https://github.com/apache/calcite/pull/1862#discussion_r397594197
########## File path: core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java ########## @@ -286,6 +286,9 @@ private SqlLibraryOperators() { opBinding -> { int precision = opBinding.collectOperandTypes().stream() .mapToInt(RelDataType::getPrecision).sum(); + // precision may be smaller than -1 when operands' precision are not be specified, + // which is not allowed. + precision = Math.max(precision, -1); Review comment: In `concat(x, y, z)`, if the precision of `x`, `y`, `z` are specified (i.e., precision != `PRECISION_NOT_SPECIFIED`), the return type is the sum of them. However, if one operand's precision is `PRECISION_NOT_SPECIFIED`, the return type should also be `PRECISION_NOT_SPECIFIED`. E.g., for `concat('aaa', cast('bb' as varchar), 'ccc')`, operand's precisions are: [3, -1, 3]. The return type's precision (3-1+3=5) is not resonable. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services