[ 
https://issues.apache.org/jira/browse/FLINK-25187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17459782#comment-17459782
 ] 

Marios Trivyzas commented on FLINK-25187:
-----------------------------------------

Only for {*}BINARY{*}, not for *VARBINARY nor BYTES.* It's the analogy of 
padding only for *CHAR* but not for *VARCHAR* nor *STRING.*

Maybe we can also have add this constraint enforcer for the sinks as well, 
[~twalthr] what do you think?

 

Btw, it seems that padding is already applied:
{noformat}
public static List<TestSpec> testData() {
    final List<TestSpec> specs = new ArrayList<>();
    specs.add(
            CastTestSpecBuilder.testCastTo(BINARY(5))
                    .fromCase(CHAR(3), "foo", new byte[] {102, 111, 
111}).build()
    );
}{noformat}
The above fails since, the result is *new byte[] \{102, 111, 111, 0, 0}* but I 
haven't found where exactly this is applied, (it's not in our cast rules).

> Apply padding for BINARY(<precision>)
> -------------------------------------
>
>                 Key: FLINK-25187
>                 URL: https://issues.apache.org/jira/browse/FLINK-25187
>             Project: Flink
>          Issue Type: Sub-task
>            Reporter: Marios Trivyzas
>            Priority: Major
>
> When the resulting byte array that is generated for a *CAST(XXX AS 
> BINARY(<precision>)* has *length* < {*}precision{*}, then it should be padded 
> with *0* to the right, to end up with a byte array of *precision* length, 
> similarly to padding with spaces for {*}CHAR(<precision>){*}.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to