[MCOL-926] UDAF returns null for 2nd or more applications against same column Created: 2017-09-15  Updated: 2017-10-26  Resolved: 2017-10-26

Status: Closed
Project: MariaDB ColumnStore
Component/s: None
Affects Version/s: 1.1.0
Fix Version/s: 1.1.1

Type: Bug Priority: Major
Reporter: David Thompson (Inactive) Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Sprint: 2017-19, 2017-20, 2017-21

 Description   

to reproduce:

create table s1(i1 int, i2 int) engine=columnstore;
insert into s1 values (1,2), (3,4);
select median(i1), avg_mode(i1) from s1;
+------------+--------------+
| median(i1) | avg_mode(i1) |
+------------+--------------+
|          2 |         NULL |
+------------+--------------+
1 row in set (0.01 sec)

doesn't matter the order or function but when you have multiple udafs applied to the same column the ones after the first ones return null



 Comments   
Comment by David Thompson (Inactive) [ 2017-09-15 ]

similar behavior in group by sql.

Comment by Daniel Lee (Inactive) [ 2017-10-24 ]

Need description of the fix. Full fix? partial fix?

Comment by David Thompson (Inactive) [ 2017-10-24 ]

This should be a full fix

Comment by David Hall (Inactive) [ 2017-10-24 ]

There's special code for duplicate aggregate functions. It tries to optimize out any duplications. This code needed to be modified since most of the aggregate code sees UDAFs as all the same. It optimized out subsequent UDAF, even though they weren't actually the same function.

Comment by David Hall (Inactive) [ 2017-10-26 ]

To add the UDAF functions:
CREATE AGGREGATE FUNCTION median returns REAL soname 'libudf_mysql.so';
CREATE AGGREGATE FUNCTION ssq returns REAL soname 'libudf_mysql.so';
CREATE AGGREGATE FUNCTION avg_mode returns REAL soname 'libudf_mysql.so';
CREATE AGGREGATE FUNCTION allnull returns INTEGER soname 'libudf_mysql.so';

Comment by Daniel Lee (Inactive) [ 2017-10-26 ]

Build verified: Github source for 1.1.1

/root/columnstore/mariadb-columnstore-server
commit f6cd94ea167789970db7b5b501569a6549495d10
Merge: 3d846d3 91b2553
Author: David.Hall <david.hall@mariadb.com>
Date: Tue Oct 24 09:15:58 2017 -0500

Merge pull request #72 from mariadb-corporation/MCOL-982

MCOL-982 Merge MariaDB 10.2.9

/root/columnstore/mariadb-columnstore-server/mariadb-columnstore-engine
commit a1c82cb2b7cfc501b64843f1cc31336303e79051
Merge: 1360de6 1601d6f
Author: benthompson15 <ben.thompson@mariadb.com>
Date: Wed Oct 25 15:59:42 2017 -0500

Merge pull request #299 from mariadb-corporation/mcol-667

Mcol 667

MariaDB [mytest]> select median(i1), avg_mode(i1) from s1;
------------------------+

median(i1) avg_mode(i1)

------------------------+

2 3

------------------------+
1 row in set (0.07 sec)

MariaDB [mytest]> select avg_mode(i1), median(i1) from s1;
------------------------+

avg_mode(i1) median(i1)

------------------------+

3 2

------------------------+
1 row in set (0.03 sec)

Generated at Thu Feb 08 02:24:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.