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

ASF GitHub Bot commented on FLINK-9559:
---------------------------------------

hequn8128 opened a new pull request #6519: [FLINK-9559] [table] The type of a 
union of CHAR columns of different lengths should be VARCHAR
URL: https://github.com/apache/flink/pull/6519
 
 
   
   ## What is the purpose of the change
   
   Currently, if the case-when expression has two branches which return string 
literal, redundant white spaces will be appended to the short string literal. 
For example, for the sql: case 1 when 1 then 'a' when 2 then 'bcd' end, the 
return value will be 'a ' of CHAR(3) instead of 'a'.
   This pr tries to solve the redundant white spaces problem.
   
   
   ## Brief change log
   
     - Override `shouldConvertRaggedUnionTypesToVarying` to true in 
`FlinkTypeSystem`, so that Calcite will return CHAR to VARCHAR when infer 
result type for CHAR with different length.
     - Adapt some old tests.
     - Add more tests.
   
   
   ## Verifying this change
   
   
   This change is already covered by existing tests, such as `testValues` in 
`JavaSqlITCase` and `testOtherExpressions` in `ScalarOperatorsTest`.
   Also add more tests in `ScalarOperatorsTest`.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> The type of a union of CHAR columns of different lengths should be VARCHAR
> --------------------------------------------------------------------------
>
>                 Key: FLINK-9559
>                 URL: https://issues.apache.org/jira/browse/FLINK-9559
>             Project: Flink
>          Issue Type: Bug
>          Components: Table API & SQL
>            Reporter: Hequn Cheng
>            Assignee: Hequn Cheng
>            Priority: Major
>              Labels: pull-request-available
>
> Currently, If the case-when expression has two branches which return string 
> literal, redundant white spaces will be appended to the short string literal. 
> For example, for the sql: case 1 when 1 then 'a' when 2 then 'bcd' end, the 
> return value will be 'a ' of CHAR(3) instead of 'a'.
> Although, this follows the behavior in strict SQL standard mode(SQL:2003). We 
> should get the pragmatic return type in a real scenario without blank-padded. 
> Happily, this problem has been fixed by 
> [CALCITE-2321|https://issues.apache.org/jira/browse/CALCITE-2321], we can 
> upgrade calcite to the next release(1.17.0) and override 
> {{RelDataTypeSystem}} in flink to configure the return type, i.e., making 
> {{shouldConvertRaggedUnionTypesToVarying()}} return true.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to