You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Rui Wang (JIRA)" <ji...@apache.org> on 2018/10/30 17:18:00 UTC

[jira] [Comment Edited] (CALCITE-2645) SESSION_END() is transformed to RexInputRef, which is always equal to SESSION_START()

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

Rui Wang edited comment on CALCITE-2645 at 10/30/18 5:17 PM:
-------------------------------------------------------------

[~danny0405]

For example, if run a query including session window, like:
```
SELECT SESSION_START(ts) as window_start, SESSION_END(ts) as window_end FROM table GROUP BY SESSION(ts).
```

I will get a LogicalProject for the select, which is LogicalProject(window_start=[$0], window_end=[$0])

So both wndow_start and window_end will be a RexInputRef to the same $0. In Beam's rules implementation, the code cannot tell which is window_start and which is window_end (what if the query is SELECT SESSION_END(ts), SESSION_START(ts))?)

TUMBLE_END and HOP_END does not have this problem because they are converted to a PLUS and TUMBLE and HOP knows what is the window size.

SESSION window only knows WINDOW gap.

 
One idea to fix it is keep a RexCall for SESSION_END, so later in rules, our code know what is it and convert it to a correct RexInputRef.


was (Author: amaliujia):
[~danny0405]

For example, if run a query including session window, like:
```
SELECT SESSION_START(ts) as window_start, SESSION_END(ts) as window_end FROM table GROUP BY SESSION(ts).
```

I will get a LogicalProject for the select, which is LogicalProject(window_start=[$0], window_end=[$0])

So both wndow_start and window_end will be a RexInputRef to the same $0. In Beam's rules implementation, the code cannot tell which is window_start and which is window_end.

TUMBLE_END and HOP_END does not have this problem because they are converted to a PLUS and TUMBLE and HOP knows what is the window size.

SESSION window only knows WINDOW gap.

 

> SESSION_END() is transformed to RexInputRef, which is always equal to SESSION_START()
> -------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2645
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2645
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Rui Wang
>            Assignee: Julian Hyde
>            Priority: Major
>
> https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql2rel/AuxiliaryConverter.java#L56
> In the AuxiliaryConverter implementation, SESSION_END() is transformed to a RexInputRef, as the same as SESSION_START(). By doing so, it cannot restored when generating physical plan because it cannot be differentiated which RexInputRef is session start, and which RexInputRef is session end. 
> Ideally, during toRel, SESSION_END can be kept as a RexCall with function information in it. So in the following step, the RexCall can be replaced as a correct input reference to GROUP BY's field.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)