Skip to content

Conversation

Tpt
Copy link
Contributor

@Tpt Tpt commented Oct 17, 2025

Use LIMIT 1 instead of a GROUP BY in this case: if there are results, they are all empty, we can just take the first one

We cannot use GROUP BY here because GROUP BY requires at least one variable in the grouping side or one aggregation function

Use LIMIT 1 instead of a GROUP BY in this case: if there are results, they are all empty, we can just take the first one

Close apache#18132
@github-actions github-actions bot added the optimizer Optimizer rules label Oct 17, 2025
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me -- thank you @Tpt

@alamb alamb changed the title ReplaceDistinctWithAggregate: do not fail when on input without columns Fix DISTINCT ON for tables with no columns (ReplaceDistinctWithAggregate: do not fail when on input without columns) Oct 17, 2025
Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Jefffrey Jefffrey added this pull request to the merge queue Oct 19, 2025
Merged via the queue into apache:main with commit b98cad6 Oct 19, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DISTINCT fails without columns in the replace_distinct_aggregate rule

3 participants