You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Feng Zhu (Jira)" <ji...@apache.org> on 2019/12/20 08:25:00 UTC

[jira] [Commented] (CALCITE-3618) WindowedAggRelSplitter.isDependent is incorrect

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

Feng Zhu commented on CALCITE-3618:
-----------------------------------

Hi [~lxian2], could you describe the issue from the perspective of an end-user and post the whole exception stack trace? Thanks!

> 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
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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`
>  
> I  have submitted a PR to fix this [https://github.com/apache/calcite/pull/1678]



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