[MDEV-15073] Generic UDAF parser code in server for windows functions Created: 2017-12-13  Updated: 2018-12-11  Resolved: 2018-11-27

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Fix Version/s: 10.4.1

Type: Task Priority: Critical
Reporter: Andrew Hutchings (Inactive) Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: 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.



 Comments   
Comment by Andrew Hutchings (Inactive) [ 2018-01-25 ]

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();
           }
         ;

Comment by Oleksandr Byelkin [ 2018-11-16 ]

UDAF == User Defined Aggregate Function

Comment by Oleksandr Byelkin [ 2018-11-16 ]

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.

Comment by Oleksandr Byelkin [ 2018-11-20 ]

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

Comment by Oleksandr Byelkin [ 2018-11-20 ]

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

Comment by Sergei Golubchik [ 2018-11-21 ]

ok to push

Generated at Thu Feb 08 08:18:29 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.