-
Notifications
You must be signed in to change notification settings - Fork 598
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
feat: support cast between integer and bool #2370
Conversation
849a8d3
to
1c10265
Compare
Signed-off-by: xyz <[email protected]>
1c10265
to
7cdbe43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing. Some suggestions for simplification:
src/expr/src/vector_op/cast.rs
Outdated
match input { | ||
0 => Ok(false), | ||
_ => Ok(true), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok(input != 0)
src/expr/src/expr/expr_unary.rs
Outdated
{ boolean, int16, general_cast }, | ||
{ boolean, int32, general_cast }, | ||
{ boolean, int64, general_cast }, | ||
{ int16, boolean, int16_to_bool }, | ||
{ int32, boolean, int32_to_bool }, | ||
{ int64, boolean, int64_to_bool }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostgreSQL only allows casting between boolean and int32. We do not need to use macro/generic to support int16 and int64.
Signed-off-by: xyz <[email protected]>
680689f
to
3e9a075
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Could you fix the clippy errors from CI? You can run ./risedev c
locally.
Codecov Report
@@ Coverage Diff @@
## main #2370 +/- ##
=======================================
Coverage 71.26% 71.26%
=======================================
Files 688 688
Lines 86985 86995 +10
=======================================
+ Hits 61987 61998 +11
+ Misses 24998 24997 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
Signed-off-by: xyz [email protected]
What's changed and what's your intention?
This pr add support for casting between integer and bool.
Cast from integer to bool: 0 -> false , other -> true.
Cast from bool to integer: false -> 0, true -> 1.
PLEASE DO NOT LEAVE THIS EMPTY !!!
Please explain IN DETAIL what the changes are in this PR and why they are needed:
Checklist
- [ ] I have written necessary docs and commentsRefer to a related PR or issue link (optional)
#112