opt: add SerializingProject exec primitive #52386
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The top-level projection of a query has a special property - it can project away
columns that we want an ordering on (e.g.
SELECT a FROM t ORDER BY b
).The distsql physical planner was designed to tolerate such cases, as they were
much more common with the heuristic planner. But the new distsql exec factory
does not; it currently relies on a hack: it detects this case by checking if the
required output ordering is
nil
. This is fragile and doesn't work in allcases.
This change adds a
SerializingProject
primitive which is like a SimpleProjectbut it forces serialization of all parallel streams into one. The new primitive
is used to enforce the final query presentation. We only need to pass column
names for the presentation, so we remove
RenameColumns
and remove the columnnames argument from
SimpleProject
(simplifying some execbuilder code).We also fix a bug in
ConstructSimpleProject
where we weren't taking thePlanToStreamColMap
into account when building the projection.Release note: None