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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]