-
Notifications
You must be signed in to change notification settings - Fork 510
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 4580 Add PostgreSql Select Distinct On #4584
Conversation
4bf0af8
to
1f2804b
Compare
Initial grammar and fixture TODO Validate Distinct On Columns match Order By Columns Integration Test
Initial attempt at annotating errors for DISTINCT ON "DISTINCT ON expression(s) must match the leftmost ORDER BY expression(s)"
I looked at the CockRoachDB implementation (compatible with Postgres) Essentially, the simplest check is to ensure the ORDER BY columns exist in the DISTINCT ON columns.
Remove the negation
1f2804b
to
e592904
Compare
* Add PostgreSql Distinct On Initial grammar and fixture TODO Validate Distinct On Columns match Order By Columns Integration Test * Add DistinctOnExpressionMixin Initial attempt at annotating errors for DISTINCT ON "DISTINCT ON expression(s) must match the leftmost ORDER BY expression(s)" * Add mixin to handle annotated errors I looked at the CockRoachDB implementation (compatible with Postgres) Essentially, the simplest check is to ensure the ORDER BY columns exist in the DISTINCT ON columns. * Can use none instead of any Remove the negation
I'm finally getting around to upgrading my project to 2.0.2 to take advantage of these changes. Did this change also have the effect of removing support for just I'm finding that to be the case but it's a backwards incompatible change with my migrations. Having to change migrations changes their hash, which is a tricky proposition using a migration tool like Flyway. |
@lnhrdt |
Initial grammar and fixture test
Mixin for Distinct On columns
Annotate Distinct On using the basic rule "The DISTINCT ON column(s) must match the leftmost ORDER BY column(s)" see https://github.com/cockroachdb/cockroach/blob/b994d025c678f495cb8b93044e35a8c59595bd78/pkg/sql/opt/optbuilder/distinct.go#L91. This should catch at compile time, instead of runtime where columns are not matching.
fixes #4580