You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Hequn Cheng (JIRA)" <ji...@apache.org> on 2018/06/09 02:21:00 UTC

[jira] [Closed] (CALCITE-2311) case when returns redundant white space

     [ https://issues.apache.org/jira/browse/CALCITE-2311?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hequn Cheng closed CALCITE-2311.
--------------------------------
    Resolution: Fixed

This was fixed by [CALCITE-2321|https://issues.apache.org/jira/browse/CALCITE-2321]. 

> case when returns redundant white space
> ---------------------------------------
>
>                 Key: CALCITE-2311
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2311
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.12.0
>            Reporter: pengzhiwei
>            Assignee: Julian Hyde
>            Priority: Major
>             Fix For: 1.17.0
>
>
> If the case-when expression has two branches which returns string literal,redundant white space will append to the short string literal  after the ReduceExpressionsRule. For example:
> {code:java}
> case when id>0 then 'a' else 'abc' end{code}
> will actually be convert to 
> {code:java}
> case when id>0 then 'a  ' else 'abc' end{code}
>  
> The reason is that the type of  'a' is CHAR(1),but CHAR(3) for 'abc',so the return type of  the case-when is CHAR(3). The RexBuilder#ensureType() method append a cast convertion for 'a' to cast it to CHAR(3) type.The ReduceExpressionsRule execute the cast convertion which fill two whilte space to 'a'.



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