Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-15204

LAG function doesn't require ORDER BY in OVER clause

    Details

      Description

      Our current implementation selects an ordering for rows implicitly. This can lead to results that look like this:

      create table t1 (a int);
      insert into t1 values (1), (2), (10), (0);
      select a, lag(a, 1) over () from t1;
      a    lag(a, 1) over ()
      1    0
      2    1
      10    2
      0    NULL
      

      The ordering used by lag is (ORDER BY a), but we don't return the rows in this order. Also, this would be quite confusing if multiple window functions are used.

      Instead of running this query like this and produce confusing results, we should return an error of the form:

      "No order list in window specification for 'LAG'"
      

        Attachments

          Activity

            People

            • Assignee:
              cvicentiu Vicentiu Ciorbaru
              Reporter:
              cvicentiu Vicentiu Ciorbaru
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: