snuyanzin commented on code in PR #28733:
URL: https://github.com/apache/flink/pull/28733#discussion_r3578372744


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java:
##########
@@ -132,9 +133,42 @@ Stream<TestSetSpec> getTestSetSpecs() {
         specs.addAll(numericBounds());
         specs.addAll(constructedTypes());
         specs.addAll(bitmapCasts());
+        specs.addAll(variantCasts());
         return specs.stream();
     }
 
+    private static List<TestSetSpec> variantCasts() {
+        // A variant is produced with PARSE_JSON so that the source column 
stays a STRING literal;
+        // there is no VARIANT literal to feed a source column directly. A 
JSON integer is stored in
+        // the smallest integer type that fits (42 -> TINYINT), and numeric 
casts are lenient, so it
+        // still widens to INT.
+        return Collections.singletonList(
+                TestSetSpec.forExpression("Cast a VARIANT produced by 
PARSE_JSON to a primitive")
+                        .onFieldsWithData("unused")
+                        .andDataTypes(STRING())
+                        .testResult(
+                                call("PARSE_JSON", "42").cast(INT()),
+                                "CAST(PARSE_JSON('42') AS INT)",
+                                42,
+                                INT().notNull())
+                        .testResult(
+                                call("PARSE_JSON", "42").cast(BIGINT()),
+                                "CAST(PARSE_JSON('42') AS BIGINT)",
+                                42L,
+                                BIGINT().notNull())
+                        .testResult(

Review Comment:
   I like it in every places it fails differently 🙈 



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