You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Steve Carlin (Jira)" <ji...@apache.org> on 2022/06/01 16:02:00 UTC

[jira] [Commented] (IMPALA-11323) Invalid inferred predicates based on casted null values being equivalent

    [ https://issues.apache.org/jira/browse/IMPALA-11323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17544993#comment-17544993 ] 

Steve Carlin commented on IMPALA-11323:
---------------------------------------

Not sure if this is the issue.  Trying to understand the code...

Two things I noticed on my first try on debugging:
1) The code above got moved to PlanNode.addConjunctsToNode()
2) This method doesn't get called on the above query.

> Invalid inferred predicates based on casted null values being equivalent
> ------------------------------------------------------------------------
>
>                 Key: IMPALA-11323
>                 URL: https://issues.apache.org/jira/browse/IMPALA-11323
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Frontend
>    Affects Versions: Impala 4.2.0
>            Reporter: Joe McDonnell
>            Assignee: Steve Carlin
>            Priority: Blocker
>              Labels: correctness
>
> This query should return two rows, but instead it returns nothing:
> {noformat}
> [localhost:21050] default> with t as (select 1 a), v as (select distinct a, cast(null as smallint)b, cast(null as smallint)c from t) select distinct a,b,c from v union all select distinct a,b,c from v;
> Fetched 0 row(s) in 0.14s{noformat}
> Without the union all, each side is producing a single row, so it stands to reason that the union all would produce two rows:
> {noformat}
> [localhost:21050] default> with t as (select 1 a), v as (select distinct a, cast(null as smallint)b, cast(null as smallint)c from t) select distinct a,b,c from v;
> +---+------+------+
> | a | b    | c    |
> +---+------+------+
> | 1 | NULL | NULL |
> +---+------+------+
> Fetched 1 row(s) in 0.14s
> {noformat}
> Both b and c are hard coded to null in the definition of v. The plan shows that it is producing a b = c predicate:
> {noformat}
> +-------------------------------------------------------------------+
> | Explain String                                                    |
> +-------------------------------------------------------------------+
> | Max Per-Host Resource Reservation: Memory=7.88MB Threads=1        |
> | Per-Host Resource Estimates: Memory=24MB                          |
> | Codegen disabled by planner                                       |
> |                                                                   |
> | PLAN-ROOT SINK                                                    |
> | |                                                                 |
> | 00:UNION                                                          |
> | |  pass-through-operands: all                                     |
> | |  row-size=5B cardinality=2                                      |
> | |                                                                 |
> | |--08:SELECT                                                      |
> | |  |  predicates: b = c                                           |
> | |  |  row-size=5B cardinality=1                                   |
> | |  |                                                              |
> | |  07:AGGREGATE [FINALIZE]                                        |
> | |  |  group by: a, CAST(NULL AS SMALLINT), CAST(NULL AS SMALLINT) |
> | |  |  row-size=5B cardinality=1                                   |
> | |  |                                                              |
> | |  06:AGGREGATE [FINALIZE]                                        |
> | |  |  group by: a, CAST(NULL AS SMALLINT)                         |
> | |  |  row-size=3B cardinality=1                                   |
> | |  |                                                              |
> | |  05:UNION                                                       |
> | |     constant-operands=1                                         |
> | |     row-size=1B cardinality=1                                   |
> | |                                                                 |
> | 04:SELECT                                                         |
> | |  predicates: b = c                                              |
> | |  row-size=5B cardinality=1                                      |
> | |                                                                 |
> | 03:AGGREGATE [FINALIZE]                                           |
> | |  group by: a, CAST(NULL AS SMALLINT), CAST(NULL AS SMALLINT)    |
> | |  row-size=5B cardinality=1                                      |
> | |                                                                 |
> | 02:AGGREGATE [FINALIZE]                                           |
> | |  group by: a, CAST(NULL AS SMALLINT)                            |
> | |  row-size=3B cardinality=1                                      |
> | |                                                                 |
> | 01:UNION                                                          |
> |    constant-operands=1                                            |
> |    row-size=1B cardinality=1                                      |
> +-------------------------------------------------------------------+
> {noformat}
> I added tracing to PlanNode's addConjunctsToNode() and the b=c conjunct is generated by Analyzer::createEquivConjuncts(). It survives the inferred identity predicate checks, because it is referring to two different slots.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org