You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Pavel Gubin (Jira)" <ji...@apache.org> on 2019/09/17 12:21:00 UTC
[jira] [Created] (CALCITE-3352) ProjectToWindowRule sets wrong
collation on generated Window
Pavel Gubin created CALCITE-3352:
------------------------------------
Summary: 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
{{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.2#803003)