On May 4, 2015, at 10:52 AM, Yi Pan <nickpa...@gmail.com> wrote:

> Just one observation that I wanted to add in: I noted that actually any
> range-based query clause on an ordered stream essentially means the need
> for a windowing method in the ordered stream scan. Is it possible to
> identify a common syntax expression from the query parser in Calcite for
> any range-based clauses on a StreamScan operator and extract the window
> spec like:
> LogicalProject(...)
>   StreamScan(table=[[STREAMS, ORDERS]], fields=[[0,1,2,3]])
> 
> To:
> LogicalProject(...)
>   LogicalWindow(<WindowSpec from the range defining expression in
> LogicalProject>)
>      StreamScan(table=[[STREAMS, ORDERS]], fields=[[0,1,2,3]])

Yes, I plan to do this.

Calcite treats LogicalWindow is a bit differently from the other logical 
operators. A query that contains a windowed aggregate such as  “SUM(units) OVER 
<window>” is first translated to a LogicalProject that contains windowed 
aggregates as if they were ordinary function calls, then ProjectToWindowRule 
converts that LogicalProject to a LogicalWindow.

But by the time Samza sees the relational expressions you can assume that all 
windowed aggregates have been moved into a LogicalWindow.

I have logged https://issues.apache.org/jira/browse/CALCITE-713.

Julian

Reply via email to