release-19.2: colexec: fix projections of AND and OR operators when NULLs are present #41503
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.
Backport 3/3 commits from #40847.
/cc @cockroachdb/release
colexec: minor clean up of vec comparators
Release justification: Category 1: Non-production code changes.
colexec: fix projections of AND and OR operators when NULLs are present
Previously, AND projection operator didn't follow the short-circuiting
logic, so it could return incorrect results. Also, the OR expression
was replaced by CASE operator, but it is not an equivalent change when
NULLs are present. This commit adds a new projOrOp operator to handle
the OR expressions.
The idea to handle the short-circuiting logic is similar to what caseOp
does: a logical operator has an input and two projection chains. First,
it runs the left chain on the input batch. Then, it "subtracts" the
tuples for which we know the result of logical operation based only on
the left side projection (e.g. if the left side is false and we're
doing AND operation, then the result is also false) and runs the right
side projection only on the remaining tuples (i.e. those that were not
"subtracted"). Next, it restores the original selection vector and
populates the result of the logical operation.
Release justification: Category 2: Bug fixes and low-risk updates to
new functionality.
Addresses: #40634.
Fixes: #40913.
Release note: None