rionmonster commented on code in PR #28437:
URL: https://github.com/apache/flink/pull/28437#discussion_r4789339725


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/TypeInferenceUtil.java:
##########
@@ -155,11 +158,63 @@ private static CallContext castArgumentsInternal(
                                 "Invalid argument type at position %d. Data 
type %s expected but %s passed.",
                                 pos, expectedType, actualType));
             }
+
+            // Beyond type-level castability, a constant DECIMAL literal must 
also fit the
+            // expected type on the value level.
+            if (throwOnInferInputFailure) {
+                validateDecimalLiteralFitsExpectedType(callContext, pos, 
expectedType);
+            }
         }
 
         return castCallContext;
     }
 
+    /**
+     * Validates that a constant {@code DECIMAL} literal argument fits the 
expected type on the
+     * value level and not only on the type level. For example, {@code 
123.456} is implicitly
+     * castable to a {@code DECIMAL(2, 2)} but would otherwise be silently 
reduced to {@code NULL}
+     * during constant folding instead of raising a type error.
+     *
+     * <p>Only a top-level {@code DECIMAL} argument is covered here; other 
value-level overflows

Review Comment:
   Yup, you're right (that it covers several other function types). I've added 
a test to exercise this in `DecimalLiteralArgumentTest` and the SQL/Table API 
PTF cases should be covered in `ProcessTableFunctionTest`.
   
   I don't have permission to edit the JIRA to add the release note (not 
currently assigned, but unsure if that would help), but I'd imagine something 
like the following would work:
   
   > A constant argument that does not fit the declared DECIMAL type of a 
function argument (e.g. 123.456 for DECIMAL(2, 2)) now fails validation with a 
ValidationException instead of evaluating to NULL. This applies to scalar, 
table, aggregate, async and process table functions. Compiled plans are not 
affected.



-- 
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]

Reply via email to