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

Pressenna commented on CALCITE-2427:
------------------------------------

Hi [~julianhyde]

I've checkout the latest master and applied the changes.

For following SQL (from above test case):
{code:sql}
update emp
set empno = (select min(empno) from emp as e where e.deptno = emp.deptno)
{code}

It now generates following RA:

{code}
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[UPDATE], 
updateColumnList=[[EMPNO]], sourceExpressionList=[[$0]], flattened=[true])
  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[$10])
    LogicalJoin(condition=[=($7, $9)], joinType=[left])
      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      LogicalAggregate(group=[{0}], EXPR$0=[MIN($1)])
        LogicalProject(DEPTNO=[$7], EMPNO=[$0])
          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
{code}


Could you verify the RA ?

> Sub-queries not supported in DML statements
> -------------------------------------------
>
>                 Key: CALCITE-2427
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2427
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.14.0, 1.15.0, 1.16.0
>            Reporter: Pressenna
>            Priority: Major
>              Labels: sub-query
>
> It appears that subqueries are not supported in DML statements.
> The yield in a NPE.
> Respective 
> [testcase|https://github.com/apache/calcite/blob/be3048300e140c5e9e5b4d23c0b27accd0af4c4d/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java#L1986]
>  is disabled with reference to CALCITE-1527.
> {code:java}
> @Ignore("CALCITE-1527")
> @Test public void testUpdateSubQuery() {
> final String sql = "update emp\n"
> + "set empno = (\n"
> + " select min(empno) from emp as e where e.deptno = emp.deptno)";
> sql(sql).ok();
> }
> {code}
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to