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

opt: add SerializingProject exec primitive #52386

Merged
merged 1 commit into from
Aug 5, 2020

Conversation

RaduBerinde
Copy link
Member

@RaduBerinde RaduBerinde commented Aug 5, 2020

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 all
cases.

This change adds a SerializingProject primitive which is like a SimpleProject
but 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 column
names argument from SimpleProject (simplifying some execbuilder code).

We also fix a bug in ConstructSimpleProject where we weren't taking the
PlanToStreamColMap into account when building the projection.

Release note: None

@RaduBerinde RaduBerinde requested a review from yuzefovich August 5, 2020 03:36
@RaduBerinde RaduBerinde requested a review from a team as a code owner August 5, 2020 03:36
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@RaduBerinde RaduBerinde force-pushed the serializing-project branch from 8738979 to af11fa9 Compare August 5, 2020 03:36
Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Thanks for working on this!

Reviewed 7 of 7 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

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 all
cases.

This change adds a `SerializingProject` primitive which is like a SimpleProject
but 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 column
names argument from `SimpleProject` (simplifying some execbuilder code).

We also fix a bug in `ConstructSimpleProject` where we weren't taking the
`PlanToStreamColMap` into account when building the projection.

Release note: None
@RaduBerinde RaduBerinde force-pushed the serializing-project branch from af11fa9 to 509b76d Compare August 5, 2020 16:13
@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 5, 2020

Build succeeded:

@craig craig bot merged commit 67a92cd into cockroachdb:master Aug 5, 2020
@RaduBerinde RaduBerinde deleted the serializing-project branch August 12, 2020 18:08
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.

3 participants