xiong duan created CALCITE-7334:
-----------------------------------
Summary: Compiling the generated Java code throws an exception
when a scalar subquery is used in the SELECT list
Key: CALCITE-7334
URL: https://issues.apache.org/jira/browse/CALCITE-7334
Project: Calcite
Issue Type: Bug
Reporter: xiong duan
The test SQL in dummy.iq:
{code:java}
!use scott
!set outputformat mysql
select
(
SELECT
COUNT(*)
FROM
"scott".emp
)
from "scott".emp as v limit 1;
+--------+
| EXPR$0 |
+--------+
| 14 |
+--------+
(1 row)
!ok
select
(
SELECT
COUNT(*)
FROM
"scott".emp
)
from "scott".emp as v where v.empno >= 2 limit 1;
+--------+
| EXPR$0 |
+--------+
| 14 |
+--------+
(1 row)
!ok
select
(SELECT
COUNT(*)
FROM
"scott".emp
WHERE
v.empno >= 2), 3
from "scott".emp as v;
EnumerableCalc(expr#0..3=[{inputs}], expr#4=[IS NULL($t3)], expr#5=[0:BIGINT],
expr#6=[CASE($t4, $t5, $t3)], expr#7=[3], EXPR$0=[$t6], EXPR$1=[$t7])
EnumerableMergeJoin(condition=[=($1, $2)], joinType=[left])
EnumerableSort(sort0=[$1], dir0=[ASC])
EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t0):INTEGER NOT NULL],
expr#9=[2], expr#10=[>=($t8, $t9)], EMPNO=[$t0], $f1=[$t10])
EnumerableTableScan(table=[[scott, EMP]])
EnumerableSort(sort0=[$0], dir0=[ASC])
EnumerableCalc(expr#0..2=[{inputs}], expr#3=[IS NOT NULL($t2)],
expr#4=[0], expr#5=[CASE($t3, $t2, $t4)], $f1=[$t0], EXPR$0=[$t5])
EnumerableNestedLoopJoin(condition=[IS NOT DISTINCT FROM($0, $1)],
joinType=[left])
EnumerableAggregate(group=[{0}])
EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t0):INTEGER NOT
NULL], expr#9=[2], expr#10=[>=($t8, $t9)], $f1=[$t10])
EnumerableTableScan(table=[[scott, EMP]])
EnumerableAggregate(group=[{1}], EXPR$0=[COUNT()])
EnumerableNestedLoopJoin(condition=[true], joinType=[inner])
EnumerableCalc(expr#0..7=[{inputs}], EMPNO=[$t0])
EnumerableTableScan(table=[[scott, EMP]])
EnumerableAggregate(group=[{0}])
EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t0):INTEGER
NOT NULL], expr#9=[2], expr#10=[>=($t8, $t9)], $f1=[$t10], $condition=[$t10])
EnumerableTableScan(table=[[scott, EMP]])
!plan
java.sql.SQLException: Error while executing SQL "select
(SELECT
COUNT(*)
FROM
"scott".emp
WHERE
v.empno >= 2), 3
from "scott".emp as v": 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;
}{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)