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

Fabian Hueske edited comment on FLINK-6228 at 4/5/17 1:28 PM:
--------------------------------------------------------------

I think that use case is not supported yet (but should be at some point).

The point is that RANK() is applied to all records in a partition and the order 
in which rank counts are assigned depends on the ORDER BY clause. If you want 
to reset the rank counter after each millisecond, you need to partition on time 
and order by amount. Rank does also not take a parameter. 

I think in SQL the query would look as follows:
{code}
SELECT timestamp, orderId, amount, rank() OVER (PARTITION BY CEIL(timestamp TO 
MILLISECOND) ORDER BY amount) FROM stream
{code}

So, we would partition on {{timestamp}} and order by {{amount}} and compute the 
{{RANK()}} function on each partition.

I don't think the current OVER window implementations are able to execute your 
use case.


was (Author: fhueske):
I think that use case is not supported yet (but should be at some point).

I think in SQL the query would look as follows:
{code}
SELECT timestamp, orderId, amount, rank() OVER (PARTITION BY CEIL(timestamp TO 
MILLISECOND) ORDER BY amount) FROM stream
{code}

So, we would partition on {{timestamp}} and order by {{amount}} and compute the 
{{RANK()}} function on each partition.

I'm not sure if the current OVER window implementations are able to execute 
your use case.

> Integrating the OVER windows in the Table API
> ---------------------------------------------
>
>                 Key: FLINK-6228
>                 URL: https://issues.apache.org/jira/browse/FLINK-6228
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API & SQL
>            Reporter: sunjincheng
>            Assignee: sunjincheng
>
> Syntax:
> {code}
> table
>    .overWindows(
>     (Rows|Range [ partitionBy value_expression , ... [ n ]] [ orderBy 
> order_by_expression] 
>       (preceding  
> UNBOUNDED|value_specification.(rows|milli|second|minute|hour|day|month|year)|CURRENTROW)
>      [following 
> UNBOUNDED|value_specification.(rows|milli|second|minute|hour|day|month|year)|CURRENTROW]
>     as alias,...[n])
>    )
>   .select( [col1,...[n]], (agg(col1) OVER overWindowAlias, … [n])
> {code}
> Implement restrictions:
> * All OVER clauses in the same SELECT clause must be exactly the same.
> * The PARTITION BY clause is optional (no partitioning results in single 
> threaded execution).
> * The ORDER BY Before the 
> [FLINK-5884|https://issues.apache.org/jira/browse/FLINK-5884]  implementation 
> orderBy may only have ‘rowtime/’proctime(for stream)/‘specific-time-field(for 
> batch).
> * FOLLOWING is not supported.
> I will soon add a user interface design document.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to