Hi,
I am trying to parse a simple query over a window. Basically the query follows
the examples on the website of using the "OVER" clause. Nevertheless I have 2
questions about this:
1) if the "time_event" field over which I want to create the window is of type
TIME, I get an error when parsing the query (see below) that the RANGE clause
is not acceptable. How is this the case as most of the example on the website
are like this ?
The query example:
SELECT STREAM user, SUM(value) OVER (ORDER BY time_event RANGE INTERVAL '1'
HOUR PRECEDING) AS recent_sum FROM data
Exception in thread "main" 16:01:38,146 ERROR
org.apache.calcite.runtime.CalciteException -
org.apache.calcite.runtime.CalciteContextException: From line 1, column 85 to
line 1, column 101: Data type of ORDER BY prohibits use of RANGE clause
org.apache.calcite.tools.ValidationException:
org.apache.calcite.runtime.CalciteContextException: From line 1, column 85 to
line 1, column 101: Data type of ORDER BY prohibits use of RANGE clause
2) if I change the type of the field to do the ordering in type long and write
the same query and replace " RANGE INTERVAL '1' HOUR PRECEDING " with "RANGE
3600 PRECEDING " - then I get the query parsed and the logical graph looks like
the one below. What is surprising is that there is not LogicalWindow. I do not
understand the logic of the parsing if the inner part of "OVER" is not
converted to window...then how can it be possible to create a rule to map this
over some window implementation?
LogicalDelta
LogicalProject(user=[$3], recent_sum=[CASE(>(COUNT($11) OVER (ORDER BY $10
RANGE BETWEEN 3600 PRECEDING AND CURRENT ROW), 0), CAST($SUM0($11) OVER (ORDER
BY $10 RANGE BETWEEN 3600 PRECEDING AND CURRENT ROW)):DOUBLE, null)])
LogicalTableScan(table=[[data]])