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

radu commented on FLINK-5654:
-----------------------------

I have another dilemma for the implementation. When we build the window 
functions to compute the aggregates we have 2 options:

1) we extract the input data stream and then apply directly the window logic on 
top just like we would work with the datastream api. For this scenario all 
parameters of the sql operator will be passed in the constructor of the window 
apply function
e.g.
inputDS=..
inputDS.windowAssigner().trigger().evictor().
apply(new WindowFunction(maxField){
//max aggregate
max = ... Raw.getField(maxField)
//sum
...
//min
...

})

2) the other option is to follow the design from Calc operator where we 
generate a text description of the window function for which we construct a 
windowRunner and use janino to compile it. This can slightly optimize things as 
some aggregation logic that might not be useful will not be implemented in the 
function (rather then in the first option when we would carry everything all 
the time

Do you have any preferences for the implementation?
Option 1 is more clean for maintenance while option 2 is more efficient

> Add processing time OVER RANGE BETWEEN x PRECEDING aggregation to SQL
> ---------------------------------------------------------------------
>
>                 Key: FLINK-5654
>                 URL: https://issues.apache.org/jira/browse/FLINK-5654
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API & SQL
>            Reporter: Fabian Hueske
>            Assignee: radu
>
> The goal of this issue is to add support for OVER RANGE aggregations on 
> processing time streams to the SQL interface.
> Queries similar to the following should be supported:
> {code}
> SELECT 
>   a, 
>   SUM(b) OVER (PARTITION BY c ORDER BY procTime() RANGE BETWEEN INTERVAL '1' 
> HOUR PRECEDING AND CURRENT ROW) AS sumB,
>   MIN(b) OVER (PARTITION BY c ORDER BY procTime() RANGE BETWEEN INTERVAL '1' 
> HOUR PRECEDING AND CURRENT ROW) AS minB
> FROM myStream
> {code}
> The following restrictions should initially apply:
> - 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 clause may only have procTime() as parameter. procTime() is a 
> parameterless scalar function that just indicates processing time mode.
> - UNBOUNDED PRECEDING is not supported (see FLINK-5657)
> - FOLLOWING is not supported.
> The restrictions will be resolved in follow up issues. If we find that some 
> of the restrictions are trivial to address, we can add the functionality in 
> this issue as well.
> This issue includes:
> - Design of the DataStream operator to compute OVER ROW aggregates
> - Translation from Calcite's RelNode representation (LogicalProject with 
> RexOver expression).



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

Reply via email to