You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "pengzhiwei (Jira)" <ji...@apache.org> on 2020/01/16 07:08:00 UTC

[jira] [Commented] (CALCITE-3738) Missing LogicalSort for insert statement

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

pengzhiwei commented on CALCITE-3738:
-------------------------------------

   I think the SQL  is not fully equivalent to the generated RelNode if we remove the LogicalSort. Maybe in some usage scenario, the target table cannot  guarantee the order of the input rows. But in some case, the target table really need the ordering of the input rows. 

   For example,I want to insert an ordered rows to a message queue which can guarantee the order of the input rows. With this default optimization,I cannot do this.

  So can we make this optimization as a RelOptRule, the physics engine can decide use or not use this rule according to the actual situation.

> Missing LogicalSort for insert statement
> ----------------------------------------
>
>                 Key: CALCITE-3738
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3738
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.19.0
>            Reporter: pengzhiwei
>            Assignee: pengzhiwei
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> The following sql statement generates a wrong logical plan which missing the LogicalSort :
> {code:java}
> insert into t select id*10,name from users order by name;{code}
> the plan is :
> {code:java}
> LogicalTableModify(table=[[t]], operation=[INSERT], flattened=[false])
>   LogicalProject(id=[*($0, 10)], name=[$1])
>     LogicalTableScan(table=[[users]])
> {code}
> This issue is introduced by the issue https://issues.apache.org/jira/browse/CALCITE-2978 
> which removes the sort by in sub-query.However the query in insert statement is not a sub-query.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)