impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe McDonnell (Code Review)" <ger...@cloudera.org>
Subject [Impala-ASF-CR] IMPALA-4792: Fix number of distinct values for a CASE with constant outputs
Date Mon, 23 Jan 2017 19:44:59 GMT
Joe McDonnell has uploaded a new change for review.

  http://gerrit.cloudera.org:8080/5768

Change subject: IMPALA-4792: Fix number of distinct values for a CASE with constant outputs
......................................................................

IMPALA-4792: Fix number of distinct values for a CASE with constant outputs

If a Case expression has only constants as return values, then the number of
distinct values can be restricted to the number of outputs.

There is a limitation to this fix:
Expr.java calculates the number of distinct values by finding any SlotRefs
in its tree and taking the maximum of the distinct values from those SlotRefs.
Due to this, this fix will only take effect if the CaseExpr is at the top level
(i.e. no function is applied on top of it). For example:

-- explaining this statement shows cardinality = 2
explain select distinct case when id = 1 then 'yes' else 'no' end
from functional.alltypes;

-- explaining this statement shows cardinality = 7300
explain select distinct char_length(case when id = 1 then 'yes' else 'no' end)
from functional.alltypes;

Change-Id: I21dbdaad8452b7e58c477612b47847dccd9d98d2
---
M fe/src/main/java/org/apache/impala/analysis/CaseExpr.java
1 file changed, 30 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/68/5768/1
-- 
To view, visit http://gerrit.cloudera.org:8080/5768
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21dbdaad8452b7e58c477612b47847dccd9d98d2
Gerrit-PatchSet: 1
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Joe McDonnell <joemcdonnell@cloudera.com>

Mime
View raw message