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

Generic UDAF parser code in server for windows functions

Details

    • Task
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 10.4.1
    • OTHER
    • None

    Description

      We currently have a patched in MariaDB's parser to support UDAFs. We need to work with the server team to do this in a more generic way.

      Attachments

        Activity

          Current patch used by ColumnStore for UDAF window functions:

          @@ -10482,6 +10478,29 @@ window_func:
                   |
                     sum_expr
                     {
          +            ((Item_sum *) $1)->mark_as_window_func_sum_expr();
          +          }
          +        |
          +          function_call_generic
          +          {
          +            /*
          +            We want to allow UDF aggregate (UDAF) functions as Window functions.
          +            function_call_generic handles UDAF, so we leverage
          +            that and then filter out anything that isn't a UDAF.
          +            */
          +        Item* item = (Item*)$1;
          +            if (item == NULL)
          +        {
          +              my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", "");
          +              MYSQL_YYABORT;
          +        }
          +            if ((item->type() != Item::SUM_FUNC_ITEM)
          +        || (((Item_sum *)item)->sum_func() != Item_sum::UDF_SUM_FUNC))
          +        {
          +              my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", ((Item_func_sp*)item)->func_name());
          +              MYSQL_YYABORT;
          +        }
          +
                       ((Item_sum *) $1)->mark_as_window_func_sum_expr();
                     }
                   ;
          

          LinuxJedi Andrew Hutchings (Inactive) added a comment - Current patch used by ColumnStore for UDAF window functions: @@ -10482,6 +10478,29 @@ window_func: | sum_expr { + ((Item_sum *) $1)->mark_as_window_func_sum_expr(); + } + | + function_call_generic + { + /* + We want to allow UDF aggregate (UDAF) functions as Window functions. + function_call_generic handles UDAF, so we leverage + that and then filter out anything that isn't a UDAF. + */ + Item* item = (Item*)$1; + if (item == NULL) + { + my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", ""); + MYSQL_YYABORT; + } + if ((item->type() != Item::SUM_FUNC_ITEM) + || (((Item_sum *)item)->sum_func() != Item_sum::UDF_SUM_FUNC)) + { + my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", ((Item_func_sp*)item)->func_name()); + MYSQL_YYABORT; + } + ((Item_sum *) $1)->mark_as_window_func_sum_expr(); } ;

          UDAF == User Defined Aggregate Function

          sanja Oleksandr Byelkin added a comment - UDAF == User Defined Aggregate Function
          sanja Oleksandr Byelkin added a comment - - edited

          The problem I see is that window function need other interface than usual aggregate.
          So it is not about only parser change and it is far from 1 day of work.

          sanja Oleksandr Byelkin added a comment - - edited The problem I see is that window function need other interface than usual aggregate. So it is not about only parser change and it is far from 1 day of work.

          For more efficient window functions support support of *_remove() call added to UDF, aggregate without it also supported as a window function.

          sanja Oleksandr Byelkin added a comment - For more efficient window functions support support of *_remove() call added to UDF, aggregate without it also supported as a window function.

          I forgot to change ORACLE parser, but there changes will be the same.

          sanja Oleksandr Byelkin added a comment - I forgot to change ORACLE parser, but there changes will be the same.

          ok to push

          serg Sergei Golubchik added a comment - ok to push

          People

            sanja Oleksandr Byelkin
            LinuxJedi Andrew Hutchings (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 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.