You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Viliam Durina (Jira)" <ji...@apache.org> on 2020/06/02 08:01:00 UTC

[jira] [Commented] (CALCITE-3780) SESSION Table-valued Function

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

Viliam Durina commented on CALCITE-3780:
----------------------------------------

The {{keycol}} argument should not have been there. The Polymorphic Table Functions specification has special support for partitioning. The signature should have been:
{code:sql}
FUNCTION SESSION(
  data TABLE PASS THROUGH WITH SET SEMANTICS,
  timecol DESCRIPTOR,
  timeout INTERVAL DAY TO SECOND
) RETURNS TABLE(wstart TIMESTAMP, 
    wend TIMESTAMP)
DETERMINISTIC
{code}

The call would look like this:
{code:sql}
SELECT W.wstart, W.wend, OI.customer, SUM(OI.price)
FROM TABLE(SESSION(
  data => TABLE(order_item) AS OI PARTITION BY customer, 
  timecol => DESCRIPTOR(order_time),
  timeout => INTERVAL '10' MINUTE)) W
GROUP BY 1, 2, 3
{code}

Notice the PARTITION BY clause when passing in the TABLE argument.

> SESSION Table-valued Function
> -----------------------------
>
>                 Key: CALCITE-3780
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3780
>             Project: Calcite
>          Issue Type: Sub-task
>            Reporter: Rui Wang
>            Assignee: Rui Wang
>            Priority: Major
>             Fix For: 1.23.0
>
>
> We can create SESSION table-valued function to replace GROUP BY SESSION for inactive gap session functionality:
> {code:sql}
> SELECT *
> FROM TABLE SESSION (
>   data => TABLE Bid ,
>   timecol => DESCRIPTOR ( bidtime ) ,
>   keycol => DESCRIPTOR(key),
>   inactive_gap => INTERVAL '10' MINUTES )
> {code}
>  
>  



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