Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-3794

Impala Count Distinct with Case Statement Generates Bad SQL

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • None
    • 8.12
    • Misc. Connectors
    • None

    Description

      Executing a query like:

      select count(distinct case when string_column='X' then bigint_column end)
      from some_vdb
      

      Translates as the following in Impala:

      SELECT COUNT(DISTINCT (CASE WHEN (`string_column` = 'X') THEN `bigint_column` ELSE CAST(NULL AS STRING) END)) as `EXPR_0` FROM `some_table`
      

      Which fails with the following error:

      AnalysisException: Incompatible return types 'BIGINT' and 'STRING' of exprs 'integer_column' and 'CAST(NULL AS STRING)'.
      

      Attachments

        Activity

          People

            rhn-engineering-shawkins Steven Hawkins
            walla2sl Scott Wallace (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: