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

release-19.2: colexec: fix projections of AND and OR operators when NULLs are present #41503

Merged
merged 3 commits into from
Oct 10, 2019

Conversation

yuzefovich
Copy link
Member

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

Release justification: Category 1: Non-production code changes.

Release note: None
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.

Release note: None
This commit adds the tracking of which operators have already been
seen, and when we encounter the same operator again, we simply print
out its name but do not recurse into the children.

Also, this commit adjusts bufferOp to be explainable and as having
one input node to make the diagram more understandable.

Release note: None
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich
Copy link
Member Author

TFTR!

@yuzefovich yuzefovich merged commit b63a868 into cockroachdb:release-19.2 Oct 10, 2019
@yuzefovich yuzefovich deleted the backport19.2-40847 branch October 10, 2019 16:54
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