[MCOL-2091] UDAF doesn't work if there are two count(distinct) in projection list Created: 2019-01-18  Updated: 2019-04-19  Resolved: 2019-04-19

Status: Closed
Project: MariaDB ColumnStore
Component/s: ExeMgr
Affects Version/s: 1.2.2
Fix Version/s: 1.2.4

Type: Bug Priority: Minor
Reporter: Roman Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 1
Labels: None

Sprint: 2019-04

 Description   

The query

select  c1,count(distinct c2) as c2,count(distinct c3) as c3, avg_mode(c4) as c4 from t1 group by c1;

returns the error

ERROR 1815 (HY000): Internal error: An unexpected condition within the query caused an internal processing error within Columnstore. Please check the log files for more details. Additional Information: error in TupleAggregateSte

.

Here are the steps to reproduce:

create table t1 (c1 int, c2 int, c3 int, c4 int)engine=columnstore;
insert into t1 values (1,2,3,4),(1,2,3,4),(1,2,3,4),(1,2,3,4);
select  c1,count(distinct c2) as c2,count(distinct c3) as c3, avg_mode(c4) as c4 from t1 group by c1;



 Comments   
Comment by David Hall (Inactive) [ 2019-04-10 ]

Strange. I ran the query multiple times. One time it worked.

Comment by Daniel Lee (Inactive) [ 2019-04-19 ]

Build verified: 1.2.4-1 nightly

[dlee@master centos7]$ cat gitversionInfo.txt
server commit:
137b9a8
engine commit:
b3a7559

Default installation does have avg_mode() install. It needs to be installed manually.

MariaDB [mytest]> CREATE AGGREGATE FUNCTION avg_mode returns REAL soname 'libudf_mysql.so';
Query OK, 0 rows affected (0.002 sec)

Reproduced the issue in 1.2.2-1

MariaDB [mytest]> select c1,count(distinct c2) as c2,count(distinct c3) as c3, avg_mode(c4) as c4 from t1 group by c1;
ERROR 1305 (42000): FUNCTION mytest.avg_mode does not exist
MariaDB [mytest]> CREATE AGGREGATE FUNCTION avg_mode returns REAL soname 'libudf_mysql.so';
Query OK, 0 rows affected (0.002 sec)

MariaDB [mytest]> select c1,count(distinct c2) as c2,count(distinct c3) as c3, avg_mode(c4) as c4 from t1 group by c1;
ERROR 1815 (HY000): Internal error: An unexpected condition within the query caused an internal processing error within Columnstore. Please check the log files for more details. Additional Information: error in TupleAggregateSte

Verified in 1.2.4-1 nightly

MariaDB [mytest]> create table t1 (c1 int, c2 int, c3 int, c4 int)engine=columnstore;
Query OK, 0 rows affected (0.115 sec)

MariaDB [mytest]> insert into t1 values (1,2,3,4),(1,2,3,4),(1,2,3,4),(1,2,3,4);
Query OK, 4 rows affected (0.278 sec)
Records: 4 Duplicates: 0 Warnings: 0

MariaDB [mytest]> select c1,count(distinct c2) as c2,count(distinct c3) as c3, avg_mode(c4) as c4 from t1 group by c1;
--------------+

c1 c2 c3 c4

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

1 1 1 4

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

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