shenzhu commented on a change in pull request #17919:
URL: https://github.com/apache/flink/pull/17919#discussion_r762351158



##########
File path: 
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java
##########
@@ -282,17 +282,15 @@ protected Configuration configuration() {
                         .build(),
                 CastTestSpecBuilder.testCastTo(BINARY(2))
                         .fromCase(BINARY(5), null, null)
-                        .fromCase(CHAR(3), "foo", new byte[] {102, 111, 111})
-                        .fromCase(VARCHAR(5), "Flink", new byte[] {70, 108, 
105, 110, 107})
-                        // https://issues.apache.org/jira/browse/FLINK-24419 - 
not trimmed to 2
-                        // bytes
-                        .fromCase(STRING(), "Apache", new byte[] {65, 112, 97, 
99, 104, 101})
+                        .fromCase(CHAR(3), "foo", new byte[] {102, 111})
+                        .fromCase(VARCHAR(5), "Flink", new byte[] {70, 108})

Review comment:
       Thanks for your detailed review!
   I added more test casts to cover "type case" and "runtime case" when 
[converting to 
`VARBINARY`](https://github.com/apache/flink/pull/17919/files#diff-27c48372e941145405a73a03dde6ce99b5e926f2d4acdc8bb8cb9021a1486ec7R327),
 however, when converting to `BINARY(3)`, seems [Calcite 1.26 will pad the 
result](https://github.com/apache/calcite/blob/calcite-1.26.0/core/src/main/java/org/apache/calcite/rex/RexBuilder.java#L1539)
 to make sure it has the same length as target type, so converting `CHAR(1)` 
with value `f` to `BINARY(3)` will still result in `{102, 0, 0}`.




-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to