[
https://issues.apache.org/jira/browse/CALCITE-3618?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated CALCITE-3618:
------------------------------------
Labels: pull-request-available (was: )
> WindowedAggRelSplitter.isDependent is incorrect
> -----------------------------------------------
>
> Key: CALCITE-3618
> URL: https://issues.apache.org/jira/browse/CALCITE-3618
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.21.0
> Reporter: Li Xian
> Priority: Major
> Labels: pull-request-available
> Attachments: Screen Shot 2019-12-20 at 3.49.09 PM.png
>
>
> WindowedAggRelSplitter isDependent is incorrect
> {code:java}
> while (!dfs.isEmpty()) {
> int source = dfs.pop();
> if (visited.contains(source)) {
> continue;
> }
> if (source == ordinal1) {
> return true;
> }
> visited.add(source);
> for (DefaultEdge e : graph.getOutwardEdges(source)) {
> int target = (int) e.target;
> if (rank.get(target) < rank.get(ordinal1)) {
> dfs.push(target);
> }
> }
> }
> {code}
> It only pushes target into dfs queue if target rank is smaller than
> ordinal1's rank, which makes it impossible to find the dependency.
> For SQL like
> {code:sql}
> select
> lag(a2, 1, 0) over (partition by "deptno" order by a1) as lagx
> from
> (
> select
> "deptno",
> "salary" / "commission" as a1,
> sum("commission") over ( partition by "deptno" order by "salary" /
> "commission") / sum("commission") over (partition by "deptno") as a2
> from
> "hr"."emps"
> )
> {code}
> It generates levels of exprs like the attached picture below which is
> incorrect. And will cause error `Error while applying rule
> ProjectToWindowRule:project`
--
This message was sent by Atlassian Jira
(v8.3.4#803005)