[MCOL-5394] JSON_ARRAYAGG in MCS works differently than in InnoDB. Created: 2023-01-18  Updated: 2023-02-01

Status: Open
Project: MariaDB ColumnStore
Component/s: None
Affects Version/s: None
Fix Version/s: Icebox

Type: Bug Priority: Major
Reporter: Sergey Zefirov Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Here's the SQL to demonstrate the problem:

DROP DATABASE IF EXISTS json_arrayagg_db;CREATE DATABASE json_arrayagg_db;
USE json_arrayagg_db;CREATE TABLE t1 (a INT, b VARCHAR(80));
INSERT INTO t1 VALUES
       (1, "Hello"),(1, "World"), (2, "This"),(2, "Will"), (2, "Work"),(2, "!"), (3, NULL),
       (1, "Hello"),(1, "World"), (2, "This"),(2, "Will"), (2, "Work"),(2, "!"), (3, NULL);
SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY a;
DROP TABLE t1;
CREATE TABLE t1 (a INT, b VARCHAR(80))ENGINE=COLUMNSTORE;
INSERT INTO t1 VALUES
       (1, "Hello"),(1, "World"), (2, "This"),(2, "Will"), (2, "Work"),(2, "!"), (3, NULL),
       (1, "Hello"),(1, "World"), (2, "This"),(2, "Will"), (2, "Work"),(2, "!"), (3, NULL);
SELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY a;

These queries return different results for row containing "[3,3]" in first column: InnoDBreturns the string "[null,null]" and MCS currently returns NULL (which is empty string in actuality).

The code in question is this:

void JsonArrayAggOrderBy::processRow(const rowgroup::Row& row)
{
  // check if this is a distinct row
  if (fDistinct && fDistinctMap->find(row.getPointer()) != fDistinctMap->end())
    return;
 
  // this row is skipped if any concatenated column is null.
  if (concatColIsNull(row))
    return;
...

It actively skips NULL rows when doing group by aggregation.


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