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

Calcite rejects valid query with multiple ORDER BY columns and constant RANGE bounds in window functions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Resolved
    • 1.34.0
    • 1.36.0
    • None

    Description

      Usually, it is not valid to specify multiple ORDER BY columns with RANGE bounds in window functions:

      SELECT sum(x) OVER (ORDER BY x,y RANGE BETWEEN 3 preceding and 4 following) from t;

      However, it is valid if both bounds are "constant" bound (CURRENT ROW, UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING), i.e:

      SELECT sum(x) OVER (ORDER BY x,y RANGE BETWEEN UNBOUNDED PRECEDING and CURRENT ROW) from t;

      (tested on PostgreSQL and SQL Server)
      Calcite will incorrectly reject it. 

      Attachments

        Issue Links

          Activity

            People

              itiels Itiel Sadeh
              itiels Itiel Sadeh
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: