Skip to content

Incorrect results of aggregation with grouping sets with single target partition #16965

@mpurins-coralogix

Description

@mpurins-coralogix

Describe the bug

When datafusion.execution.target_partitions is set to 1 then following query gives incorrect results -- select id from (select 'id' as id union all select 'id' as id order by id) group by grouping sets ((id), ());

To Reproduce

Run following in datafusion-cli

DataFusion CLI v49.0.0
> set datafusion.execution.target_partitions = 1;
0 row(s) fetched.
Elapsed 0.013 seconds.

> select id from (select 'id' as id union all select 'id' as id order by id) group by grouping sets ((id), ());
+------+
| id   |
+------+
| id   |
| NULL |
| id   |
+------+
3 row(s) fetched.
Elapsed 0.016 seconds.

Expected behavior

Query should give following result

+------+
| id   |
+------+
| id   |
| NULL |
+------+

Additional context

Postgres gives following

psql (17.5 (Homebrew))
Type "help" for help.

postgres=# select id from (select 'id' as id union all select 'id' as id) group by grouping sets ((id), ());
 id
----

 id
(2 rows)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions