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

Aggregate Window Functions

    XMLWordPrintable

    Details

    • Sprint:
      10.2.4-4

      Description

      With a few exceptions, most native aggregate functions are supported as window functions.
      https://mariadb.com/kb/en/library/aggregate-functions-as-window-functions/

      In MDEV-7773, support for creating of custom aggregate functions was added.
      This task proposes to extend that feature and allow custom aggregate functions to be used as window functions

      An example of a creating a custom aggregate function is given below:

      create aggregate function agg_sum(x INT) returns double
      begin
        declare z double default 0;
        declare continue handler for not found return z;
        loop
          fetch group next row;
          set z = z + x;
        end loop;
      end|
      

      This functions can be used in the following query:

      create table balances (id int, amount int);
      insert into balances values (1, 10), (2, 20), (3, 30);
       
      select agg_sum(amount) from balances;
      

      After this task is complete the following must also work:

      select agg_sum(amount) over (order by id);
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              varun Varun Gupta
              Reporter:
              varun Varun Gupta
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated: