Tpt opened a new issue, #18132:
URL: https://github.com/apache/datafusion/issues/18132
### Describe the bug
`DISTINCT` on an input without columns should not be rewritten to a `GROUP
BY` that requires at least one group but into a `LIMIT 1`
### To Reproduce
On queries like `SELECT DISTINCT * FROM empty` where `empty` is a table
without columns, the `replace_distinct_aggregate` optimization fails with
`Error: Unexpected(Context("Optimizer rule 'replace_distinct_aggregate'
failed", Plan("Aggregate requires at least one grouping or aggregate
expression. Aggregate without grouping expressions nor aggregate expressions is
logically equivalent to, but less efficient than, VALUES producing single row.
Please use VALUES instead.` because it tries to generate an empty aggregate.
### Expected behavior
_No response_
### Additional context
_No response_
--
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]