Paul Rogers created IMPALA-7950:
-----------------------------------
Summary: Implicit cast does not propagate NDV
Key: IMPALA-7950
URL: https://issues.apache.org/jira/browse/IMPALA-7950
Project: IMPALA
Issue Type: Bug
Components: Frontend
Affects Versions: Impala 3.1.0
Reporter: Paul Rogers
Assignee: Paul Rogers
See the scenario in IMPALA-7949 in which we have the following SELECT list
expression:
{code:sql}
cast(0 as double) = id
{code}
Analysis of this expression inserts an implicit cast to force {{id}} to the
same {{DOUBLE}} type as the constant:
{code:sql}
CAST(0 AS DOUBLE) = CAST(id AS DOUBLE)
{code}
The code to do this is in the {{CastExpr(Type targetType, Expr e)}}
constructor. This constructor attempts to analyze the new cast node, but does
so incorrectly. (The code is a copy of the analysis code rather than a call to
it.) The code calls {{computeNumDistinctValues()}} which determines that the
cast is not a constant, and sets the NDV to -1.
The correct answer is to propagate NDV up from the child element. Since NDV of
id is 7300, the NDV of the cast should also be 7300. An even better answer is
to use the existing analysis code to do the analysis, rather than making a copy.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)