Also this query in Calcite :

 "select * from ("
                + "select s.orders.productid , avg(units) OVER (product
ROWS BETWEEN 10 PRECEDING and 5 FOLLOWING)"                   + " as m10, "
                + "AVG(units) OVER (product RANGE INTERVAL '7' DAY
PRECEDING) AS d7 "
                + "from s.orders "
                + " WINDOW product AS (PARTITION BY productId)) "
                + "where m10>d7 "
         );

gives me after optimization the following plan, that doesn't have any
window boundaries :

LogicalFilter(condition=[>($1, $2)])
  LogicalProject(productid=[$0], m10=[CAST(/($1, $2)):INTEGER NOT NULL],
d7=[CAST(/($3, $4)):INTEGER NOT NULL])
    LogicalProject(productid=[$0], $1=[$2], $2=[$3], $3=[$4], $4=[$5])
      LogicalWindow(window#0=[window(partition {0} order by [] rows between
UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING aggs [SUM($1), COUNT($1)])],
window#1=[window(partition {0} order by [] range between UNBOUNDED
PRECEDING and UNBOUNDED FOLLOWING aggs [SUM($1), COUNT($1)])])
        LogicalProject(productid=[$1], units=[$2])
          LogicalTableScan(table=[[s, orders]])

2016-10-18 20:23 GMT+03:00 Γιώργος Θεοδωράκης <giwrgosrth...@gmail.com>:

> Hi,
>
> I was wondering if there is any possible way to define windows with SQl in
> Calcite for queries that don't have an aggregate function? For example, I
> want to define the queries from Linear Road Benchmark of the STREAM project
> (http://infolab.stanford.edu/stream/cql-benchmark.html):
>
> 1)
> SELECT DISTINCT car_id
> FROM CarSegStr [RANGE 30 SECONDS];
>
> 2)
> SELECT car_id, exp_way, dir, seg
> FROM CarSegStr [PARTITION BY car_id ROWS 1], CurActiveCars
> WHERE CarSegStr.car_id = CurActiveCars.car_id;
>
> Thank you in advance,
> George.
>

Reply via email to