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