]
Steven Hawkins updated TEIID-3794:
----------------------------------
Fix Version/s: (was: 8.12.x)
Impala Count Distinct with Case Statement Generates Bad SQL
-----------------------------------------------------------
Key: TEIID-3794
URL:
https://issues.jboss.org/browse/TEIID-3794
Project: Teiid
Issue Type: Feature Request
Components: Misc. Connectors
Affects Versions: 8.12
Reporter: Scott Wallace
Assignee: Steven Hawkins
Executing a query like:
{noformat}
select count(distinct case when string_column='X' then bigint_column end)
from some_vdb
{noformat}
Translates as the following in Impala:
{noformat}
SELECT COUNT(DISTINCT (CASE WHEN (`string_column` = 'X') THEN `bigint_column`
ELSE CAST(NULL AS STRING) END)) as `EXPR_0` FROM `some_table`
{noformat}
Which fails with the following error:
{noformat}
AnalysisException: Incompatible return types 'BIGINT' and 'STRING' of
exprs 'integer_column' and 'CAST(NULL AS STRING)'.
{noformat}