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

sql: use IndexFetchSpec for zigzag join #78295

Merged
merged 3 commits into from
Mar 24, 2022

Conversation

RaduBerinde
Copy link
Member

rowexec: follow-up cleanup for EncodedKey in zigzagjoiner

The zig-zag joiner code still uses Bytes instead of EncodedKey for
the encoded key. This works because the fixed values are encoded using
VALUE encoding, and the value encodings are the same for DBytes and
DEncodedKey.

This commit updates the zigzag joiner to use the correct EncodedKey
type. The code no longer needs to special case inverted indexes -
with the addition of support for EncodedKey in keyside.Encode, the
general code path can now be used.

Release note: None

sql: clean up ZigZagJoinerSpec

This change cleans up the zig-zag joiner spec: we move the per-side
information into a Side sub-message and use a list of Sides instead of
many parallel lists. Other misc cleanup in the zigzag joiner code is
included.

Release note: None

sql: use IndexFetchSpec for zigzag join

This commit changes the zigzag joiner to use IndexFetchSpec for the
two sides instead of table and index descriptors. The internal schema
of the zigzag joiner is changed to match the fetched columns,
simplifying the execution code.

This change necessitates fixes on the planning side - we weren't
determining the necessary scan columns correctly (this wasn't a
problem when the internal schema had all table columns and we were
relying on the execution layer to figure out what is needed).

Release note: None

@RaduBerinde RaduBerinde requested review from mgartner, yuzefovich and a team March 22, 2022 22:01
@RaduBerinde RaduBerinde requested a review from a team as a code owner March 22, 2022 22:01
@cockroach-teamcity
Copy link
Member

This change is Reviewable

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.

Very nice cleanup! :lgtm:

Reviewed 2 of 2 files at r1, 5 of 5 files at r2, 27 of 27 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @RaduBerinde)


pkg/sql/rowexec/zigzagjoiner_test.go, line 232 at r3 (raw file):

					},
					{
						FetchSpec: makeFetchSpec(t, empty, "d", "a,b,d"),

This should be highRangeDesc.


pkg/sql/rowexec/zigzagjoiner_test.go, line 248 at r3 (raw file):

				Sides: []execinfrapb.ZigzagJoinerSpec_Side{
					{
						FetchSpec: makeFetchSpec(t, empty, "c", "a,b,c"),

Here the order of empty and highRangeDesc is switched.

Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

🤩 :lgtm:

Reviewed 2 of 2 files at r1, 5 of 5 files at r2, 27 of 27 files at r3, all commit messages.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @RaduBerinde)

The zig-zag joiner code still uses `Bytes` instead of `EncodedKey` for
the encoded key. This works because the fixed values are encoded using
VALUE encoding, and the value encodings are the same for `DBytes` and
`DEncodedKey`.

This commit updates the zigzag joiner to use the correct `EncodedKey`
type.  The code no longer needs to special case inverted indexes -
with the addition of support for `EncodedKey` in `keyside.Encode`, the
general code path can now be used.

Release note: None
This change cleans up the zig-zag joiner spec: we move the per-side
information into a Side sub-message and use a list of Sides instead of
many parallel lists. Other misc cleanup in the zigzag joiner code is
included.

Release note: None
This commit changes the zigzag joiner to use IndexFetchSpec for the
two sides instead of table and index descriptors. The internal schema
of the zigzag joiner is changed to match the fetched columns,
simplifying the execution code.

This change necessitates fixes on the planning side - we weren't
determining the necessary scan columns correctly (this wasn't a
problem when the internal schema had all table columns and we were
relying on the execution layer to figure out what is needed).

Release note: None
Copy link
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

TFTRs!

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @yuzefovich)


pkg/sql/rowexec/zigzagjoiner_test.go, line 232 at r3 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

This should be highRangeDesc.

Done.


pkg/sql/rowexec/zigzagjoiner_test.go, line 248 at r3 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

Here the order of empty and highRangeDesc is switched.

Done.

@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 24, 2022

Build succeeded:

@craig craig bot merged commit 9f90d41 into cockroachdb:master Mar 24, 2022
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.

4 participants