Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.10.0
-
None
Description
The jdbc adapter adapter should push down the OVER clause for all dialects that support window functions.
At the moment the Rel to SQL conversion ignores the 'OVER(...)'. The RexOver expression is treated as a plain RexCall and the RexOver#window attribute is not converted into SQL.
For example if the following sql query (using Postgres dialect):
SELECT "id", "device_id", "transaction_value", "account_id", "ts_millis", MAX("ts_millis") OVER(partition by "device_id") as "last_version_number" FROM "HAWQ"."transaction" WHERE "device_id" = 1445
is pushed down to the jdbc like this:
SELECT "id", "device_id", "transaction_value", "account_id", "ts_millis", MAX("ts_millis") AS "last_version_number" FROM "transaction" WHERE "device_id" = 1445
The OVER clause is completely dropped! Here is the plan:
JdbcToEnumerableConverter JdbcProject(id=[$0], device_id=[$1], transaction_value=[$2], account_id=[$3], ts_millis=[$4], last_version_number=[MAX($4) OVER (PARTITION BY $1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)]) JdbcFilter(condition=[=($1, 1445)]) JdbcTableScan(table=[[HAWQ, transaction]])
Attachments
Issue Links
- relates to
-
CALCITE-1174 When generating SQL, translate SUM0(x) to COALESCE(SUM(x), 0)
- Closed