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

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

The padding is done because we are using literals for the test: 
*RexBuilderL883:* 

 
{noformat}
return this.makeBinaryLiteral(padRight((ByteString)value, 
type.getPrecision()));{noformat}
does the padding.

 

 

>From our *WordCountSQLExample:*

 
{noformat}

{noformat}
*SELECT CAST(word AS BINARY(10)), CAST('foo' AS BINARY(10))*

gives:

 
{noformat}
+--------------------------------+--------------------------------+
|                         EXPR$0 |                         EXPR$1 |
+--------------------------------+--------------------------------+
|                          Hello |                     foo        |
|                           Ciao |                     foo        |
+--------------------------------+--------------------------------+{noformat}
So currently, we have inconsistency, and we only do padding for literals, but 
not for actual values.

> 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