Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-7750

Prune trivial ELSE clause in CASE simplification

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • Impala 3.0
    • None
    • Frontend
    • None
    • ghx-label-3

    Description

      A trivial optimization is to omit ELSE if it adds no value:

      CASE WHEN id = 10 THEN id ELSE NULL END
      

      The ELSE case defaults to null if not provided, so the above can be rewritten to:

      CASE WHEN id = 10 THEN id END
      

      Also, the simplification can omit the trailing WHEN clause if it returns NULL. For example:

      CASE WHEN id = 0 THEN 10 WHEN id = 1 THEN NULL END
      

      Should be simplified to:

      CASE WHEN id = 0 THEN 10 END
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Paul.Rogers Paul Rogers
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: