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
sql: fix distsql planning issue with optimizer (streaming aggregation) #31825
sql: fix distsql planning issue with optimizer (streaming aggregation) #31825
Conversation
3b023a3
to
d089bf9
Compare
c028b93
to
8cf5e62
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 13 of 13 files at r1.
Reviewable status: complete! 1 of 0 LGTMs obtained (and 1 stale)
pkg/sql/opt/exec/execbuilder/relational_builder.go, line 98 at r1 (raw file):
} // reqOrdering converts an OrderingChoice to a ColumnOrdering (according to the
reqOrdering -> sqlOrderingFromChoice
8cf5e62
to
54420ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTRs!
Reviewable status: complete! 2 of 0 LGTMs obtained
pkg/sql/opt/exec/execbuilder/relational_builder.go, line 98 at r1 (raw file):
Previously, rytaft wrote…
reqOrdering -> sqlOrderingFromChoice
Done.
bors r+ |
Build failed |
The distsql planner looks at physical properties of various plan nodes to figure out what orderings it needs to preserve when merging data from multiple nodes. These are passed as required orderings in the exec.Factory, but not for all operators - only those for which it would actually matter. There is a code path related to setting up streaming aggregations which was unaccounted for which looks at the ordering of the input node. To fix this, we now pass required orderings to filters and projections. I looked at all the operators and the rest either: - never produce an ordering as far as the optimizer is concerned (VirtualScan, HashJoin, ScalarGroupBy, SetOp, ProjectSet); or - they pass through the input ordering unchanged (Distinct); or - they cannot be distributed (Limit, Ordinality). Release note (bug fix): Fixed an issue which causes invalid results or an "incorrectly ordered stream" error with streaming aggregations (in some cases).
54420ef
to
f04fc30
Compare
bors r+ |
31825: sql: fix distsql planning issue with optimizer (streaming aggregation) r=RaduBerinde a=RaduBerinde The distsql planner looks at physical properties of various plan nodes to figure out what orderings it needs to preserve when merging data from multiple nodes. These are passed as required orderings in the exec.Factory, but not for all operators - only those which would actually matter. There is a code path related to setting up streaming aggregations which was unaccounted for which looks at the ordering of the input node. To fix this, we now pass required orderings to filters and projections. I looked at all the operators and the rest either: - never produce an ordering as far as the optimizer is concerned (VirtualScan, HashJoin, ScalarGroupBy, SetOp, ProjectSet); or - they pass through the input ordering unchanged (Distinct); or - they cannot be distributed (Limit, Ordinality). Release note (bug fix): Fixed an issue which causes invalid results or an "incorrectly ordered stream" error with streaming aggregations (in some cases). Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
Build succeeded |
The distsql planner looks at physical properties of various plan nodes
to figure out what orderings it needs to preserve when merging data
from multiple nodes. These are passed as required orderings in the
exec.Factory, but not for all operators - only those which would
actually matter.
There is a code path related to setting up streaming aggregations
which was unaccounted for which looks at the ordering of the input
node.
To fix this, we now pass required orderings to filters and
projections. I looked at all the operators and the rest either:
(VirtualScan, HashJoin, ScalarGroupBy, SetOp, ProjectSet); or
Release note (bug fix): Fixed an issue which causes invalid results or
an "incorrectly ordered stream" error with streaming aggregations (in
some cases).