You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Timo Walther (Jira)" <ji...@apache.org> on 2021/10/01 11:38:00 UTC

[jira] [Commented] (FLINK-24413) Casting to a CHAR() and VARCHAR() doesn't trim the string to the specified precision

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

Timo Walther commented on FLINK-24413:
--------------------------------------

I think it is ok to be strict for CAST. At other locations we will not enforce the length and it will still remain best effort. Can we also check how more recent system do it such as Spark, Hive, Snowflake?
[~jark] what is your opinion here? In any case, we will introduce a config option for all the cast changes to reintroduce the old behavior.

> Casting to a CHAR() and VARCHAR() doesn't trim the string to the specified precision
> ------------------------------------------------------------------------------------
>
>                 Key: FLINK-24413
>                 URL: https://issues.apache.org/jira/browse/FLINK-24413
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table SQL / API
>            Reporter: Marios Trivyzas
>            Priority: Major
>
> *CAST**('abcdfe' AS CHAR(3))* should trim the string to 3 chars but currently returns the whole string *'abcdfe'*.
>  
> PostgreSQL and Oracle for example behave as such:
> postgres=# select '123456afas'::char(4);
>  bpchar 
>  --------
>  1234
>  (1 row)
> postgres=# select '123456afas'::varchar(5);
>  varchar 
>  ---------
>  12345
>  (1 row)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)