-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
optbuilder: Fix bugs with subqueries, DISTINCT, and ORDER BY #24309
Conversation
Review status: 0 of 10 files reviewed at latest revision, all discussions resolved, all commit checks successful. pkg/sql/opt/exec/execbuilder/testdata/aggregate, line 27 at r1 (raw file):
This is odd - we are rendering the same column multiple times.. There should only be one render for column5.. Or are they different columns which have the same label for some reason? Also, how come the corresponding testcase in pkg/sql/opt/optbuilder/orderby.go, line 145 at r1 (raw file):
kind of confused why we modify the last column in the scope here? Is it the column added by pkg/sql/opt/optbuilder/project.go, line 223 at r1 (raw file):
[nit] why not set this before appending? e.g. Comments from Reviewable |
Review status: 0 of 10 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. pkg/sql/opt/exec/execbuilder/testdata/aggregate, line 27 at r1 (raw file): Previously, RaduBerinde wrote…
The
pkg/sql/opt/optbuilder/orderby.go, line 145 at r1 (raw file): Previously, RaduBerinde wrote…
Yep it's added by pkg/sql/opt/optbuilder/project.go, line 223 at r1 (raw file): Previously, RaduBerinde wrote…
I wanted to avoid copying twice... but I can change it if you think it would be more readable. Comments from Reviewable |
Review status: 0 of 10 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. pkg/sql/opt/exec/execbuilder/testdata/aggregate, line 27 at r1 (raw file): Previously, rytaft wrote…
Ah, indeed, reviewboard hid those diffs from me haha It seems semantically dubious to have a project that creates the same column multiple times (it only makes any sense if the renderings are identical). pkg/sql/opt/optbuilder/project.go, line 223 at r1 (raw file): Previously, rytaft wrote…
Maybe just hide it inside a helper function Comments from Reviewable |
1084077
to
a4200fc
Compare
Review status: 0 of 18 files reviewed at latest revision, 3 unresolved discussions. pkg/sql/opt/exec/execbuilder/testdata/aggregate, line 27 at r1 (raw file): Previously, RaduBerinde wrote…
Removed all the extra projections! pkg/sql/opt/optbuilder/orderby.go, line 145 at r1 (raw file): Previously, rytaft wrote…
Done. pkg/sql/opt/optbuilder/project.go, line 223 at r1 (raw file): Previously, RaduBerinde wrote…
Done. Comments from Reviewable |
Review status: 0 of 16 files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. pkg/sql/opt/exec/execbuilder/testdata/aggregate, line 27 at r1 (raw file): Previously, rytaft wrote…
👍 pkg/sql/opt/optbuilder/project.go, line 157 at r2 (raw file):
[nit] appendColumn could return pkg/sql/opt/optbuilder/util.go, line 136 at r2 (raw file):
[nit] this suggests cols and items can have different lengths, I'd just use len(cols). The loop below can never add more than that anyway Comments from Reviewable |
This commit fixes several miscellaneous issues. 1. Subqueries with aggregation and without a FROM clause were causing the outer query to incorrectly act as if it were in a grouping context. This commit fixes the issue by making sure the scope of the subquery is different than the scope of the outer query. 2. Queries with DISTINCT and ORDER BY in which the ORDER BY was ordering on an expression that was also part of the SELECT list were failing. This commit fixes the issue by reusing the existing projection for the ORDER BY column. 3. Several redundant columns were previously being synthesized for identical expressions. This commit fixes the issue by reusing existing columns wherever possible. Release note: None
TFTR! Updated. Review status: 0 of 16 files reviewed at latest revision, 3 unresolved discussions. pkg/sql/opt/optbuilder/project.go, line 157 at r2 (raw file): Previously, RaduBerinde wrote…
Done. pkg/sql/opt/optbuilder/util.go, line 136 at r2 (raw file): Previously, RaduBerinde wrote…
Done. Comments from Reviewable |
Reviewed 2 of 10 files at r1, 11 of 14 files at r2, 3 of 3 files at r3. Comments from Reviewable |
bors r=RaduBerinde Review status: 0 of 16 files reviewed at latest revision, 3 unresolved discussions, some commit checks pending. Comments from Reviewable |
24309: optbuilder: Fix bugs with subqueries, DISTINCT, and ORDER BY r=RaduBerinde a=rytaft This commit fixes several miscellaneous issues. 1. Subqueries with aggregation and without a `FROM` clause were causing the outer query to incorrectly act as if it were in a grouping context. This commit fixes the issue by making sure the scope of the subquery is different than the scope of the outer query. 2. Queries with `DISTINCT` and `ORDER BY` in which the `ORDER BY` was ordering on an expression that was also part of the `SELECT` list were failing. This commit fixes the issue by reusing the existing projection for the `ORDER BY` column. 3. Several redundant columns were previously being synthesized for identical expressions. This commit fixes the issue by reusing existing columns wherever possible. Release note: None 24345: storage: don't require consensus for no-op requests r=tschottdorf a=nvanbenschoten Fixes #23942. During evaluation, a request can result in having no effect for a variety of reasons. For instance, a PushTxnRequest may arrive at a transaction record to find that it is already ABORTED, in which case there's nothing for it to do. Before this change, we were still requiring that these empty results be proposed through Raft. This change fixes this by detecting empty results and bypassing consensus completely. Release note (performance improvement): Write requests that result in no-ops are no longer proposed through Raft.
Build succeeded |
This commit fixes several miscellaneous issues.
FROM
clause werecausing the outer query to incorrectly act as if it were in
a grouping context. This commit fixes the issue by making
sure the scope of the subquery is different than the scope
of the outer query.
DISTINCT
andORDER BY
in which theORDER BY
was ordering on an expression that was also part of the
SELECT
list were failing. This commit fixes the issue byreusing the existing projection for the
ORDER BY
column.for identical expressions. This commit fixes the issue by
reusing existing columns wherever possible.
Release note: None