Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2311

case when returns redundant white space

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.12.0
    • Fix Version/s: 1.17.0
    • Component/s: core
    • Labels:
      None

      Description

      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:

      case when id>0 then 'a' else 'abc' end

      will actually be convert to 

      case when id>0 then 'a  ' else 'abc' end

       

      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'.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                pzw2018 pengzhiwei
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: