[
https://issues.apache.org/jira/browse/CALCITE-2645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16669067#comment-16669067
]
Rui Wang commented on CALCITE-2645:
-----------------------------------
[~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)