[
https://issues.apache.org/jira/browse/CALCITE-5470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17676276#comment-17676276
]
Thomas Rebele commented on CALCITE-5470:
----------------------------------------
In the visualization, the LogicalSort changes the set after the SortRemoveRule.
This seems very strange to me. Is this the way the algorithm is expected to
work?
!SortRemoveRule-after.png|width=1172,height=471!
> VolcanoPlanner removes a necessary sort
> ---------------------------------------
>
> Key: CALCITE-5470
> URL: https://issues.apache.org/jira/browse/CALCITE-5470
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.32.0
> Reporter: Thomas Rebele
> Priority: Major
> Attachments: SortRemoveRule-after.png, SortRemoveRule-before.png,
> sqlline.log, test.patch
>
>
> A test case with the VolcanoPlanner produces an unexpected result
> ([^test.patch], applied on 4bebdb07c2f45a95c9a4fdf81e9bcfbdd11a15de). A
> logical plan that roughly corresponds to {{SELECT a*a FROM
> (VALUES(-10),(2),(3)) T(a) ORDER BY a*a}} produces a physical plan that is
> not sorted:
> {noformat}
> logical plan:
> LogicalSort(sort0=[$0], dir0=[ASC])
> LogicalProject($f0=[*($0, $0)])
> LogicalValues(tuples=[[{ -10 }, { 2 }, { 3 }]])
> {noformat}
> The result should be 4, 9, 100.
> {noformat}
> physical plan:
> EnumerableProject($f0=[*($0, $0)])
> EnumerableValues(tuples=[[{ -10 }, { 2 }, { 3 }]]){noformat}
> If I understand the physical plan correctly, its result would be 100, 4, 9.
> Using sqlline gives the correct result (see [^sqlline.log]), so the problem
> could be in the test itself.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)