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

Invalid case statements do not raise syntax errors

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Not A Bug
    • Affects Version/s: Impala 2.0.1
    • Fix Version/s: None
    • Component/s: None
    • Environment:
      Shell version: Impala Shell v2.0.1-cdh5 (cc09df0) built on Wed Nov 19 10:57:34 PST 2014
      Server version: impalad version 2.0.1-cdh5 RELEASE (build cc09df07d93c79351052eef2f4e5baf52373dc33)

      Description

      It looks like Impala does not throw an error on what I believe to be an invalid CASE statement.

      In the form CASE exp WHEN val, Impala incorrectly accepts an expression for val when it should error. We inadvertently used the wrong form of CASE and couldn't find the error. I think what we did was incorrect, in which case an error would have saved us a bunch of time.

      We did this:

      Query: select min, case min when min < 500 then 1 when min < 10000 then 2 else 3 end as bin from metrics limit 10
      +-------------+-----+
      | min         | bin |
      +-------------+-----+
      | 3906785280  | 3   |
      | 0           | 3   |
      | 15604977664 | 3   |
      | 0           | 3   |
      | 0           | 3   |
      | 103081248   | 3   |
      | 0           | 3   |
      | 419225600   | 3   |
      | 0           | 3   |
      | 0           | 3   |
      +-------------+-----+
      

      When we meant this:

      Query: select min, case when min < 500 then 1 when min < 10000 then 2 else 3 end as bin from metrics limit 10
      +-----------+-----+
      | min       | bin |
      +-----------+-----+
      | 147390464 | 3   |
      | 7619616   | 3   |
      | 0         | 1   |
      | 1         | 1   |
      | 0         | 1   |
      | 0         | 1   |
      | 0         | 1   |
      | 1         | 1   |
      | 68.75     | 1   |
      | 0         | 1   |
      +-----------+-----+
      

        Attachments

          Activity

            People

            • Assignee:
              cchanning Chris Channing
              Reporter:
              esammer_impala_c74d Eric Sammer
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: