You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "viirya (via GitHub)" <gi...@apache.org> on 2026/08/23 16:51:31 UTC
Re: [I] GROUP BY constant with aggregation function and with empty input magically summons a row [datafusion]
viirya commented on issue #15734:
URL: https://github.com/apache/datafusion/issues/15734#issuecomment-5387167357
This appears to be fixed on current `main` — I can no longer reproduce it.
Both variants from the report now return zero rows:
```sql
SELECT 'wat' AS key, count(1) AS c FROM (SELECT * FROM unnest(array[]::bigint[])) AS b(field) GROUP BY key;
-- 0 rows
```
and the same against a registered empty table. The optimized plan keeps the grouping rather than dropping it:
```
Aggregate: groupBy=[[Utf8("wat")]], aggr=[[count(Int64(1))]]
```
The fix looks to be #22132 ("fix: eliminate group by constant empty input", merged 2026-07-27), which matches the root cause @Dandandan identified here — `EliminateGroupByConstant` now declines to eliminate constant GROUP BY expressions when doing so would remove *all* of the grouping expressions:
```rust
if redundant.is_empty() || required.is_empty() {
return Ok(Transformed::no(LogicalPlan::Aggregate(aggregate)));
}
```
That PR closed #11748 but not this one, so this issue looks safe to close as already fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org