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

JING ZHANG commented on CALCITE-4337:
-------------------------------------

About an example of a query before and after the syntax change. I would use the 
example in [session table function 
document|https://calcite.apache.org/docs/reference.html#session] [2].
{color:#000000}Old syntax demo:{color}
{code:java}
//代码占位符
SELECT * FROM TABLE(
  SESSION(
    TABLE orders,
    DESCRIPTOR(rowtime),
    DESCRIPTOR(product),
    INTERVAL '20' MINUTE));

-- or with the named params
-- note: the DATA param must be the first
SELECT * FROM TABLE(
  SESSION(
    DATA => TABLE orders,
    TIMECOL => DESCRIPTOR(rowtime),
    KEY => DESCRIPTOR(product),
    SIZE => INTERVAL '20' MINUTE));
{code}
 
New syntax demo is as follows, the difference is use PARTITION BY clause to 
replace KEY DESCRIPTOR.
{code:java}
SELECT * FROM TABLE(
  SESSION(
    TABLE orders PARTITION BY product,
    DESCRIPTOR(rowtime),
    INTERVAL '20' MINUTE));

-- or with the named params
-- note: the DATA param must be the first
SELECT * FROM TABLE(
  SESSION(
    DATA => TABLE orders PARTITION BY product,
    TIMECOL => DESCRIPTOR(rowtime),
    SIZE => INTERVAL '20' MINUTE));
{code}
 

> Supports PARTITION BY clause for table function table argument
> --------------------------------------------------------------
>
>                 Key: CALCITE-4337
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4337
>             Project: Calcite
>          Issue Type: New Feature
>          Components: core
>    Affects Versions: 1.26.0
>            Reporter: Danny Chen
>            Assignee: Danny Chen
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: image-2021-09-30-11-04-33-474.png, 
> image-2021-09-30-11-05-12-400.png, image-2021-09-30-11-05-42-033.png
>
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> An example from the SQL standard 2016 Polymorphic Table Functions:
> {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}



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

Reply via email to