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

fix: support NULL return values from CASE statements #3531

Merged
merged 6 commits into from
Oct 15, 2019

Conversation

big-andy-coates
Copy link
Contributor

@big-andy-coates big-andy-coates commented Oct 11, 2019

Description

Fixes: #3405, #3344

This commit enhances the processing of CASE statements so that both THEN and the default return types can be NULL.

At least one branch must be non-null so that KSQL can determine the result type of the statement.

All non-null branches must have the same result schema, i.e. we don't (yet) do any implicit casting of numeric types.

The commit also improves some error messages by using KSQL types rather than connect schema types so that error messages use, for example, BIGINT rather than Schema{INT64}.

Testing done

Usual

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

This commit enhances the processing of `CASE` statements so that both `THEN` and the default return types can be `NULL`.

At least one branch must be non-null so that KSQL can determine the result type of the statement.

All non-null branches must have the same result schema, i.e. we don't (yet) do any implicit casting of numeric types.

The commit also improves some error messages by using KSQL types rather than connect schema types so that error messages use, for example, `BIGINT` rather than `Schema{INT64}`.
@big-andy-coates big-andy-coates requested a review from a team as a code owner October 11, 2019 10:32
*/
public boolean canUpCast(final SqlBaseType to) {
public boolean canImplicitlyCast(final SqlBaseType to) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to make the intent more clear.

Copy link
Contributor

Choose a reason for hiding this comment

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

nice

Copy link
Contributor

@vcrfxia vcrfxia left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @big-andy-coates !

@vcrfxia vcrfxia requested a review from a team October 14, 2019 21:37
@vcrfxia vcrfxia changed the title fix(3405): support NULL return values from CASE statements fix: support NULL return values from CASE statements Oct 14, 2019
Copy link
Contributor

@purplefox purplefox left a comment

Choose a reason for hiding this comment

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

LGTM just some nits

*/
public boolean canUpCast(final SqlBaseType to) {
public boolean canImplicitlyCast(final SqlBaseType to) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@big-andy-coates big-andy-coates merged commit eb9e41b into confluentinc:master Oct 15, 2019
@big-andy-coates big-andy-coates deleted the case_nulls branch October 16, 2019 08:10
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.

Cannot return NULL from CASE
3 participants