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: better error message on illegal arithmetic with NULL values #7554

Merged
merged 13 commits into from May 20, 2021

Conversation

cprasad1
Copy link
Member

@cprasad1 cprasad1 commented May 19, 2021

Description

This PR makes the error handling better when we try to do arithmetic with NULL.

ksql> SELECT NULL + 1 FROM s1 EMIT CHANGES;
Error processing expression (null + 1). Arithmetic on types null and INTEGER are not supported.

ksql> SELECT MAP(1 := 'cat') + NULL FROM s1 EMIT CHANGES;
Error processing expression: (MAP(1:='cat') + null). Arithmetic on types MAP<INTEGER, STRING> and null are not supported.

ksql> SELECT Array[1,2,3] + NULL FROM s1 EMIT CHANGES;
Error processing expression: (ARRAY[1, 2, 3] + null). Arithmetic on types ARRAY<INTEGER> and null are not supported.

ksql> SELECT 5.0 / NULL FROM s1 EMIT CHANGES;
Error processing expression: (5.0 / null). Arithmetic on types DECIMAL(2, 1) and null are not supported.

ksql> SELECT NULL * NULL FROM s1 EMIT CHANGES;
Error processing expression: (null * null). Arithmetic on types null and null are not supported.

Testing done

  • manual testing
  • Unit testing
  • RQTT

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 #")

@cprasad1 cprasad1 requested a review from a team as a code owner May 19, 2021 20:53
@cprasad1 cprasad1 marked this pull request as draft May 19, 2021 20:53
@cprasad1 cprasad1 marked this pull request as ready for review May 19, 2021 22:45
Copy link
Contributor

@agavra agavra left a comment

Choose a reason for hiding this comment

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

Nice! A few nits before merging

Copy link
Member

@AlanConfluent AlanConfluent left a comment

Choose a reason for hiding this comment

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

Maybe it's outside the scope of this PR, but might be good to have tests for other expression types, e.g. COL > 1 AND NULL where we have a NULL literal used in other areas. I know this is a lot of surface area potentially.

@AlanConfluent
Copy link
Member

LGTM

Copy link
Contributor

@guozhangwang guozhangwang left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@agavra agavra left a comment

Choose a reason for hiding this comment

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

Thanks @cprasad1!

@cprasad1 cprasad1 changed the title fix: better error message on illegal arithmetic fix: better error message on illegal arithmetic with NULL values May 20, 2021
@cprasad1 cprasad1 merged commit 867a587 into confluentinc:master May 20, 2021
@cprasad1 cprasad1 deleted the null_handling_error branch May 20, 2021 07:16
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.

None yet

4 participants