Fabian Hueske created FLINK-8651:
------------------------------------

             Summary: Add support for different event-time OVER windows in a 
query
                 Key: FLINK-8651
                 URL: https://issues.apache.org/jira/browse/FLINK-8651
             Project: Flink
          Issue Type: New Feature
          Components: Table API & SQL
    Affects Versions: 1.5.0
            Reporter: Fabian Hueske


Right now, Table API and SQL queries only support multiple OVER window 
aggregations, but all OVER windows must be of the same type.

For example the following query is currently supported:
{code:java}
SELECT c, b, 
  COUNT(a) OVER (PARTITION BY c ORDER BY rowtime RANGE BETWEEN INTERVAL '1' 
SECOND PRECEDING AND CURRENT ROW),
  SUM(a) OVER (PARTITION BY c ORDER BY rowtime RANGE BETWEEN INTERVAL '1' 
SECOND PRECEDING AND CURRENT ROW)
FROM T1
{code}
If we would change the interval or partitioning attribute of the {{SUM(a)}} 
aggregation's window, the query could not be executed.

We can add support for multiple different windows by splitting the query and 
joining it back.
 This would require an optimizer rule, that rewrites a plan from
{code:java}
IN -> OverAgg(window-A, window-B) -> OUT
{code}
to
{code:java}
                     /-OverAgg(window-A)-\
IN -> Calc(uniq-id)-<                     >-WindowJoin(uniq-id, rowtime) -> OUT 
           
                     \-OverAgg(window-B)-/
{code}

The unique id should consist of three components: the timestamp, the parallel 
index of the function instance, and a counter that just wraps around. One of 
the aggregates can be projected to only the required fields and the window join 
would join on uniq-id and timestamp equality (when we support FOLLOWING 
boundaries, we would have to join on a time range).



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

Reply via email to