apache / apache/datafusion

Incorrect results of aggregation with grouping sets with single target partition

Open
#16,965 1 comment 0 reactions 1 assignee Claimed by @chenkovsky View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### 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)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.