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

Haisheng Yuan edited comment on CALCITE-3352 at 9/19/19 11:55 PM:
------------------------------------------------------------------

You are mixing physical properties with logical operators. Only physical 
operators should request distribution and collation properties. Otherwise, what 
is the point of separating logical and physical operators?


was (Author: hyuan):
You mixing physical properties with logical operators. Only physical operators 
should request distribution and collation properties. Otherwise, what is the 
point of separating logical and physical operators?

> ProjectToWindowRule sets wrong collation on generated Window
> ------------------------------------------------------------
>
>                 Key: CALCITE-3352
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3352
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.21.0
>            Reporter: Pavel Gubin
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> {{ProjectToWindowRule}} sets the collocation of the {{Project}} it applies to 
> on the generated {{LogicalWindow}} which is wrong, because the collation of 
> the input can be different and Window doesn't change the collation. So the 
> collation of the generated {{LogicalWindow}} should be the same as on the 
> input (not the output).
> The following test in {{RelOptRulesTest}} reproduces the issue:
> {code:java}
>   @Test public void testWindowOnSortedInput() {
>     // Create a customized test with RelCollation trait in the test cluster.
>     Tester tester = new TesterImpl(getDiffRepos(), true, true, false, false,
>         true, null, null) {
>       @Override public RelOptPlanner createPlanner() {
>         return new MockRelOptPlanner(Contexts.empty()) {
>           @Override public List<RelTraitDef> getRelTraitDefs() {
>             return ImmutableList.of(RelCollationTraitDef.INSTANCE);
>           }
>           @Override public RelTraitSet emptyTraitSet() {
>             return RelTraitSet.createEmpty().plus(
>                 RelCollationTraitDef.INSTANCE.getDefault());
>           }
>         };
>       }
>     };
>     final HepProgram preProgram = new HepProgramBuilder()
>         .addRuleInstance(SortProjectTransposeRule.INSTANCE)
>         .build();
>     final HepProgram program = HepProgram.builder()
>         .addRuleInstance(ProjectToWindowRule.PROJECT)
>         .build();
>     final String sql = "select mgr, deptno, sum(sal) over (partition by 
> deptno)\n"
>         + "from emp\n"
>         + "order by mgr, deptno";
>     RelNode r = checkPlanning(tester, preProgram, new HepPlanner(program), 
> sql);
>     RelCollation c = 
> r.getInput(0).getTraitSet().getTrait(RelCollationTraitDef.INSTANCE);
>     assertEquals("Collation is incorrect", "[3, 7]", c.toString());
>   }
> {code}



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

Reply via email to