[ 
https://issues.apache.org/jira/browse/CALCITE-7409?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated CALCITE-7409:
------------------------------------
    Labels: pull-request-available  (was: )

> MERGE JOIN condition cannot contain IS NOT DISTINCT FROM
> --------------------------------------------------------
>
>                 Key: CALCITE-7409
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7409
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.41.0
>            Reporter: Zhen Chen
>            Assignee: Zhen Chen
>            Priority: Major
>              Labels: pull-request-available
>
> Executing the SQL query will result in a LINQ4J error using CoreQuidemTest.
> {code:java}
> select e.ename,
>   (select count(*)
>     from emp as f
>     where f.comm is not distinct from e.comm) as c
> from emp as e; {code}
> Error message:
> {code:java}
> java.sql.SQLException: Error while executing SQL "select e.ename,
>   (select count(*)
>     from emp as f
>     where f.comm is not distinct from e.comm) as c
> from emp as e": Error while compiling generated Java code:
> public static class Record1_0 implements java.io.Serializable {
>   public long f0;
>   public Record1_0() {}
>   public boolean equals(Object o) {
>     if (this == o) {
>       return true;
>     }
>     if ((!(o instanceof Record1_0))) {
>       return false;
>     }
>     return this.f0 == ((Record1_0) o).f0;
>   }
>   public int hashCode() {
>     int h = 0;
>     h = org.apache.calcite.runtime.Utilities.hash(h, this.f0);
>     return h;
>   }
>   public int compareTo(Record1_0 that) {
>     final int c;
>     c = org.apache.calcite.runtime.Utilities.compare(this.f0, that.f0);
>     if (c != 0) {
>       return c;
>     }
>     return 0;
>   }
>   public String toString() {
>     return "{f0=" + this.f0 + "}";
>   }
> }
> ...... {code}
> Plan is:
> {code:java}
> EnumerableCalc(expr#0..6=[{inputs}], expr#7=[IS NULL($t6)], 
> expr#8=[0:BIGINT], expr#9=[CASE($t7, $t8, $t6)], ENAME=[$t1], C=[$t9])
>   EnumerableMergeJoin(condition=[AND(=($3, $5), IS NOT DISTINCT FROM($2, 
> $4))], joinType=[left])        <----- here
>     EnumerableSort(sort0=[$3], dir0=[ASC])
>       EnumerableCalc(expr#0..7=[{inputs}], expr#8=[IS NULL($t6)], 
> proj#0..1=[{exprs}], COMM=[$t6], $f3=[$t8])
>         EnumerableTableScan(table=[[scott, EMP]])
>     EnumerableSort(sort0=[$1], dir0=[ASC])
>       EnumerableCalc(expr#0..4=[{inputs}], expr#5=[IS NOT NULL($t4)], 
> expr#6=[0], expr#7=[CASE($t5, $t4, $t6)], proj#0..1=[{exprs}], EXPR$0=[$t7])
>         EnumerableHashJoin(condition=[AND(IS NOT DISTINCT FROM($0, $2), IS 
> NOT DISTINCT FROM($1, $3))], joinType=[left])
>           EnumerableAggregate(group=[{0, 1}])
>             EnumerableCalc(expr#0..7=[{inputs}], expr#8=[IS NULL($t6)], 
> COMM=[$t6], $f3=[$t8])
>               EnumerableTableScan(table=[[scott, EMP]])
>           EnumerableAggregate(group=[{0, 1}], EXPR$0=[COUNT()])
>             EnumerableNestedLoopJoin(condition=[OR(AND(IS NULL($3), $1), 
> =($3, $0))], joinType=[inner])
>               EnumerableAggregate(group=[{0, 1}])
>                 EnumerableCalc(expr#0..7=[{inputs}], expr#8=[IS NULL($t6)], 
> COMM=[$t6], $f3=[$t8])
>                   EnumerableTableScan(table=[[scott, EMP]])
>               EnumerableCalc(expr#0..7=[{inputs}], EMPNO=[$t0], COMM=[$t6])
>                 EnumerableTableScan(table=[[scott, EMP]]) {code}
> MERGE JOINs containing the IS NOT DISTINCT FROM expression in the join key 
> will cause abnormal execution. I think we can temporarily prevent MERGE JOINs 
> with such join keys from being generated.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to