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

exec: Fix NULL expression handling in CASE and AND operators #40657

Merged
merged 1 commit into from
Sep 14, 2019

Conversation

rohany
Copy link
Contributor

@rohany rohany commented Sep 11, 2019

This change fixes the CASE and AND operators when nulls were used as
expressions, which caused different errors than nulls existing as data
within the batches. Additionally, this change increases the safety of
the vectorized engine by disallowing the engine to plan
constNullOperators without knowing the "type" of the null to avoid
having the same panic arise. To get around this, when the "type" of the
null is known, a constNullOperator with a known type can be planned.
This is a temporary fix for the release. To be properly fixed, datum
nulls need to be aware of their type post typechecking, instead of being
"unknown".

Release justification: This PR fixes known panics within the vectorized engine.

Fixes #40526.

Release note: None

@rohany rohany requested review from jordanlewis, yuzefovich and a team September 11, 2019 00:15
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rohany rohany force-pushed the const-nulls branch 3 times, most recently from 9283991 to 16c5901 Compare September 11, 2019 18:09
Copy link
Member

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

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

Need to update the commit message to Release justificatoin: blah to satisfy the linter now.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto, @jordanlewis, @rohany, and @yuzefovich)


pkg/sql/distsqlrun/column_exec_setup.go, line 962 at r1 (raw file):

// plan constNullOperators in the case that we know the "type" of the null. It is currently
// unsafe to plan a constNullOperator when we don't know the type of the null.
func planTypedMaybeNullProjectionOperators(

This is fine but isn't it unfortunate that everyone going forward will have to remember which to use? Can we make the other variant return an error if its type is unknown? That should always be an error right?

Copy link
Contributor Author

@rohany rohany left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto, @jordanlewis, and @yuzefovich)


pkg/sql/distsqlrun/column_exec_setup.go, line 962 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

This is fine but isn't it unfortunate that everyone going forward will have to remember which to use? Can we make the other variant return an error if its type is unknown? That should always be an error right?

The other variant does now in this PR. I guess its less of remember which one to use and consciously pick this one when you know you can handle a null value.

Copy link
Contributor Author

@rohany rohany left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto, @jordanlewis, and @yuzefovich)


pkg/sql/distsqlrun/column_exec_setup.go, line 962 at r1 (raw file):

Previously, rohany (Rohan Yadav) wrote…

The other variant does now in this PR. I guess its less of remember which one to use and consciously pick this one when you know you can handle a null value.

  • the other variant does throw an error

Copy link
Member

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @asubiotto, @rohany, and @yuzefovich)


pkg/sql/distsqlrun/column_exec_setup.go, line 962 at r1 (raw file):

Previously, rohany (Rohan Yadav) wrote…
  • the other variant does throw an error

Ahh I didn't notice, but it's obvious now that you point it out. SGTM.

@rohany rohany force-pushed the const-nulls branch 3 times, most recently from 87ce20d to f4a67b6 Compare September 13, 2019 23:32
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:

Reviewed 3 of 4 files at r1, 1 of 1 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @asubiotto and @rohany)

This change fixes the CASE and AND operators when nulls were used as
expressions, which caused different errors than nulls existing as data
within the batches. Additionally, this change increases the safety of
the vectorized engine by disallowing the engine to plan
constNullOperators without knowing the "type" of the null to avoid
having the same panic arise. To get around this, when the "type" of the
null is known, a constNullOperator with a known type can be planned.
This is a temporary fix for the release. To be properly fixed, datum
nulls need to be aware of their type post typechecking, instead of being
"unknown".

Release justification: This PR fixes known panics within the vectorized engine.

Fixes cockroachdb#40526.

Release note: None
@rohany
Copy link
Contributor Author

rohany commented Sep 14, 2019

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 14, 2019

Build failed

@rohany
Copy link
Contributor Author

rohany commented Sep 14, 2019

I have a release justification though...

bors r+

craig bot pushed a commit that referenced this pull request Sep 14, 2019
40657: exec: Fix NULL expression handling in CASE and AND operators r=rohany a=rohany

This change fixes the CASE and AND operators when nulls were used as
expressions, which caused different errors than nulls existing as data
within the batches. Additionally, this change increases the safety of
the vectorized engine by disallowing the engine to plan
constNullOperators without knowing the "type" of the null to avoid
having the same panic arise. To get around this, when the "type" of the
null is known, a constNullOperator with a known type can be planned.
This is a temporary fix for the release. To be properly fixed, datum
nulls need to be aware of their type post typechecking, instead of being
"unknown".

Release justification: This PR fixes known panics within the vectorized engine.

Fixes #40526.

Release note: None

Co-authored-by: Rohan Yadav <rohany@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Sep 14, 2019

Build succeeded

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.

exec: CASE expressions with nulls error out
4 participants