Details

    • 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

            Arhant Arhant Jain added a comment -

            Thanks Vicentiu

            Please clarify me.
            As you said " start looking into the Item_sum class and particularly subclasses of it like Item_sum_sum".
            Can you please detail about it and where should I look for these subclasses.

            Arhant Arhant Jain added a comment - Thanks Vicentiu Please clarify me. As you said " start looking into the Item_sum class and particularly subclasses of it like Item_sum_sum". Can you please detail about it and where should I look for these subclasses.

            Hi Arhant

            You can find the classes using your IDE's search feature or a regular expression search tool like grep, ack, etc.

            I suggested in my previous post to investigate the add() method and try to figure out how it is used inside the server. Did you manage to set up a breakpoint and have the debugger stop at it when a query to the server is issued? What did you try to do so far? Providing more details as to what actually got you stuck will help in getting a more coherent reply

            cvicentiu Vicențiu Ciorbaru added a comment - Hi Arhant You can find the classes using your IDE's search feature or a regular expression search tool like grep, ack, etc. I suggested in my previous post to investigate the add() method and try to figure out how it is used inside the server. Did you manage to set up a breakpoint and have the debugger stop at it when a query to the server is issued? What did you try to do so far? Providing more details as to what actually got you stuck will help in getting a more coherent reply
            tavneet Tavneet Singh added a comment -

            Hi Varun and Vincent, was any progress made on this issue during the last iteration ? I have built the project and will start looking at the window and aggregate functions touch points in the code. I will also pick up a recent beginner friendly task to get familiar with the codebase.

            tavneet Tavneet Singh added a comment - Hi Varun and Vincent, was any progress made on this issue during the last iteration ? I have built the project and will start looking at the window and aggregate functions touch points in the code. I will also pick up a recent beginner friendly task to get familiar with the codebase.

            tavneet No progress has been done since last GSoC. Feel free to have a look and ask any questions you might have. I recommend sending an email to maria-developers mailing list. You stand a much higher chance of getting a reply there, rather than though JIRA only.

            cvicentiu Vicențiu Ciorbaru added a comment - tavneet No progress has been done since last GSoC. Feel free to have a look and ask any questions you might have. I recommend sending an email to maria-developers mailing list. You stand a much higher chance of getting a reply there, rather than though JIRA only.
            tavneet Tavneet Singh added a comment - - edited

            Hi @Vicențiu Ciorbaru @Varun,

            I have set up the debugger and have some idea about the code flow for the regular aggregate function (sum) and the custom aggregate function posted by Varun.

            I had a couple of queries which I have asked on the email and I am also posting here.

            1. In do_add from decimal.c, there are three parts with comments - /* part 1 - MY_MAX(frac) ... min (frac) /, / part 2 - MY_MIN(frac) ... MY_MIN(intg) */. Can someone please elaborate on what do the comments mean ?
            2. In Item_sum_sum::add_helper, there is an unlikely branch for variable direct_added. Can someone please give an idea about when will direct added be true ? In fact in all the uses for direct_added, it is always in an unlikely branch in Item_sum.cc.
            3. What is the design choice behind the struct decimal_t in decimal.h ? Why are we representing the numbers in this format (Is it helpful for handling floating point inaccuracies and overflows )?
            tavneet Tavneet Singh added a comment - - edited Hi @Vicențiu Ciorbaru @Varun, I have set up the debugger and have some idea about the code flow for the regular aggregate function (sum) and the custom aggregate function posted by Varun. I had a couple of queries which I have asked on the email and I am also posting here. In do_add from decimal.c, there are three parts with comments - /* part 1 - MY_MAX(frac) ... min (frac) /, / part 2 - MY_MIN(frac) ... MY_MIN(intg) */. Can someone please elaborate on what do the comments mean ? In Item_sum_sum::add_helper, there is an unlikely branch for variable direct_added. Can someone please give an idea about when will direct added be true ? In fact in all the uses for direct_added, it is always in an unlikely branch in Item_sum.cc. What is the design choice behind the struct decimal_t in decimal.h ? Why are we representing the numbers in this format (Is it helpful for handling floating point inaccuracies and overflows )?

            People

              psergei Sergei Petrunia
              varun Varun Gupta (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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