Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug preventing orderedAggregate and distinctAggregator from being used together (one approach) #577

Conversation

shane-circuithub
Copy link
Contributor

This PR contains two commits.

The first commit adds a (failing) test case demonstrating the inability to combine orderedAggregate and distinctAggregator together, even in the limited cases allowed by PostgreSQL. The problem is that PostgreSQL only allows this if the expressions given in the ORDER BY clause match the expressions given as arguments to the aggregation function.

The second commit fixes this bug. It does so by adding Eq and Ord constraints to PrimExpr and using them to detect identical expressions anywhere within the Aggregate, and when we rename the expressions we maintain a Map of already-renamed expressions such that identical expressions will be renamed to the same symbol, fulfilling PostgreSQL's restriction.

@shane-circuithub
Copy link
Contributor Author

This is based on the refactoring in #575.

@shane-circuithub shane-circuithub force-pushed the aggregate-distinct-order-by-fix-1 branch from 179c631 to 00c0e07 Compare October 6, 2023 00:32
@shane-circuithub
Copy link
Contributor Author

Closing in favour of #578.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant