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

Maryann Xue commented on CALCITE-1278:
--------------------------------------

The fix is straightforward and easy, but I had a problem when I was trying to 
add a test into JdbcFrontLinqBackTest. It hangs till it ends with an OOM error.
{code}
  @Test public void testDelete() {
    final List<JdbcTest.Employee> employees = new ArrayList<>();
    CalciteAssert.AssertThat with = mutable(employees);
    with.query("select * from \"foo\".\"bar\"")
        .returns(
            "empid=0; deptno=0; name=first; salary=0.0; commission=null\n");
    with.query("insert into \"foo\".\"bar\" select * from \"hr\".\"emps\"")
        .updates(4);
    with.query("select count(*) as c from \"foo\".\"bar\"")
        .returns("C=5\n");
    with.query("delete from \"foo\".\"bar\" "
        + "where \"deptno\" = 10")
        .typeIs("");
    with.query("select \"name\", count(*) as c from \"foo\".\"bar\" "
        + "group by \"name\"")
        .returnsUnordered(
            "name=Eric; C=1",
            "name=first; C=1");
  }
{code}

> CalciteSignature's ColumnMetaData info is wrong for DML (except INSERT)
> -----------------------------------------------------------------------
>
>                 Key: CALCITE-1278
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1278
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.7.0
>            Reporter: Maryann Xue
>            Assignee: Maryann Xue
>
> DELETE, as one type of TableModify operation, has the same RelDataType as 
> INSERT, which is RelRecordType(ROWCOUNT INTEGER). But during "prepare" stage, 
> the corresponding ColumnMetaData info becomes inconsistent, due to:
> {code}
>       preparedResult = preparingStmt.prepareSql(
>           sqlNode, Object.class, validator, true);
>       switch (sqlNode.getKind()) {
>       case INSERT:
>       case EXPLAIN:
>         // FIXME: getValidatedNodeType is wrong for DML
>         x = RelOptUtil.createDmlRowType(sqlNode.getKind(), typeFactory);
>         break;
>       default:
>         x = validator.getValidatedNodeType(sqlNode);
>       }
> {code}
> I've noticed that there is a "FIXME: getValidatedNodeType is wrong for DML". 
> Guess that's the root cause, and RelOptUtil.createDmlRowType() is probably a 
> workaround? For now, we can simply include DELETE and other TableModify 
> Operation in the first switch case.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to