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

Throw an error when arguments to window functions are window functions

Details

    Description

      CREATE TABLE t1(a INT, b INT);
      INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
      

      MariaDB [test]> SELECT NTILE(MAX(a) OVER (PARTITION BY a)) OVER (PARTITION BY a ORDER BY b) FROM t1;
      ERROR 4074 (HY000): Window functions can not be used as arguments to group functions.
      

      MariaDB [test]> SELECT FIRST_VALUE(MAX(a) OVER (PARTITION BY a)) OVER (ORDER BY a) AS x FROM t1 GROUP BY a;
      

      This query just crashes.
      We should ensure that for FIRST_VALUE window function, we don't allow a window function in its arguments.

      Attachments

        People

          varun Varun Gupta (Inactive)
          varun Varun Gupta (Inactive)
          Votes:
          0 Vote for this issue
          Watchers:
          2 Start watching this issue

          Dates

            Created:
            Updated:
            Resolved:

            Git Integration

              Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.