You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
54808: sql: introduce RIGHT SEMI and RIGHT ANTI joins r=yuzefovich a=yuzefovich
**sql: introduce RIGHT SEMI and RIGHT ANTI joins**
This commit introduces right semi and right anti joins which will give
an ability to the optimizer to control on which relation we're building
the hash table (in case of the hash join). This will allow us to bake in
the assumption that we're building the hash table on the right side into
the row-execution (we already have this assumption in the vectorized
hash join).
Additionally, this commit adds several assertions to different types of
joiners about which join types they support as well as fixes the
`joinerBase` code to handle the join types that emit only columns from
one side (previously, it just happened to work because the left side
columns were always in the output).
Release note: None
**rowexec: move hash joiner unit tests**
This commit renames "joinerTestCase" to "hashJoinerTestCase" since those
tests are only used by the hash joiner and moves the corresponding code
to hashjoiner_test.go. I believe that originally the intention was to
generalize them to use in several joiners types, but that intention was
never implemented, and since we're moving towards deprecating these
processors, I don't think it ever will.
Release note: None
**rowexec: support right semi and right anti hash joins**
This commit adds support for right semi and right anti hash joins which
turned out to be pretty easy to do. This paves the way for refactoring
the hash joiner code to hard-code that we're always storing the right
side.
Addresses: #54707.
Release note: None
**rowexec: clean up the hash joiner**
This commit cleans up the hash joiner by baking in the assumption that
we're always building the hash table on the right side. The assumption
allows us to remove the buffering logic (which attempted to find
a shorter relation, until a certain threshold), and we will now rely on
the optimizer to request an appropriate join type with the right
relation having smaller cardinality.
Release note: None
**colexec: support right semi and right anti in merge joiner**
This commit adds the support for right semi and right anti merge joins.
This turned out to be relatively easy when following the examples of
left semi and left anti (with the new right cases being simpler because
of not having to worry about set-operation joins which are intertwined
with left semi and left anti joins). The testing is done by "mirroring"
existing test cases for left semi and left anti joins.
Addresses: #54707.
Release note: None
**colexec: support right semi and right anti in the hash joiner**
The support of right semi and right anti in the hash joiner required
extending the idea of tracking whether build rows matched which was
already being done in case of full/right outer joins. Notable difference
is that right semi/anti joins don't emit any output during the probing
phase, so the "collection" simply tracks the matched rows whereas the
output is fully emitted in `hjEmittingRight` phase of the algorithm.
Note that because the external hash joiner falls back to the disk-backed
merge joiner in some cases it is important to point out that the
vectorized merge joiner already supports all join types.
Addresses: #54707.
Release note: None
**rowexec: support right semi and right anti in the merge joiner**
The support of right semi and right anti merge joiner is added via
tracking which rows have been matched on the right side. In case of
right semi we remember that the right row is matched, emit it, and then
make sure to ignore it (to not emit for the second time). In case of
right anti, all unmatched right rows will be emitted (similar to
right/full outer joins). This support was mostly added in order to test
the correctness of the vectorized merge joiner (I don't expect the
optimizer to ever plan right semi/anti merge joins).
Addresses: #54707.
Release note: None
**opt: plan right semi and right anti hash joins**
This commit utilizes the recently added right semi and right anti joins
in the optimizer. Internally, those join types are represented as the
same opt operator with the only changes being switching two input
relations if the left has smaller cardinality when execbuilding the hash
join (with the same change to the costing).
Fixes: #54707.
Release note: None
Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
0 commit comments