Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1506

Push OVER Clause to underlying SQL via JDBC adapter

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.10.0
    • Fix Version/s: 1.11.0
    • Component/s: jdbc-adapter
    • Labels:
      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

          Activity

            People

            • Assignee:
              julianhyde Julian Hyde
              Reporter:
              tzolov Christian Tzolov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: