You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "James Starr (Jira)" <ji...@apache.org> on 2022/12/06 01:09:00 UTC
[jira] [Updated] (CALCITE-5421) SqlToRel should populate corralateId for join with corralated query in HAVING condition
[ https://issues.apache.org/jira/browse/CALCITE-5421?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
James Starr updated CALCITE-5421:
---------------------------------
Description:
{code:java}
class SqlToRelConverterTest extends SqlToRelTestBase {
...
@Test void testInCorrelatedSubQueryInHavingRex() {
final String sql = "select sum(sal) as s\n"
+ "from emp e1\n"
+ "group by deptno\n"
+ "having count(*) > 2\n"
+ "and exists(\n"
+ " select true\n"
+ " from emp e2\n"
+ " where e1.deptno = e2.deptno)";
sql(sql).withExpand(false).ok();
}
{code}
Generates the following plan where the project with a subquery does not have correlate id:
{code}
LogicalProject(S=[$1])
LogicalFilter(condition=[AND(>($2, 2), EXISTS({
LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
}))])
LogicalAggregate(group=[{0}], S=[SUM($1)], agg#1=[COUNT()])
LogicalProject(DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
{code}
was:
{code:java}
class SqlToRelConverterTest extends SqlToRelTestBase {
...
@Test void testInCorrelatedSubQueryInHavingRex() {
final String sql = "select sum(sal) as s\n"
+ "from emp e1\n"
+ "group by deptno\n"
+ "having count(*) > 2\n"
+ "and exists(\n"
+ " select true\n"
+ " from emp e2\n"
+ " where e1.deptno = e2.deptno)";
sql(sql).withExpand(false).ok();
}
{code}
> SqlToRel should populate corralateId for join with corralated query in HAVING condition
> ---------------------------------------------------------------------------------------
>
> Key: CALCITE-5421
> URL: https://issues.apache.org/jira/browse/CALCITE-5421
> Project: Calcite
> Issue Type: Improvement
> Reporter: James Starr
> Assignee: James Starr
> Priority: Major
>
> {code:java}
> class SqlToRelConverterTest extends SqlToRelTestBase {
> ...
> @Test void testInCorrelatedSubQueryInHavingRex() {
> final String sql = "select sum(sal) as s\n"
> + "from emp e1\n"
> + "group by deptno\n"
> + "having count(*) > 2\n"
> + "and exists(\n"
> + " select true\n"
> + " from emp e2\n"
> + " where e1.deptno = e2.deptno)";
> sql(sql).withExpand(false).ok();
> }
> {code}
> Generates the following plan where the project with a subquery does not have correlate id:
> {code}
> LogicalProject(S=[$1])
> LogicalFilter(condition=[AND(>($2, 2), EXISTS({
> LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> }))])
> LogicalAggregate(group=[{0}], S=[SUM($1)], agg#1=[COUNT()])
> LogicalProject(DEPTNO=[$7], SAL=[$5])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)