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

feat: support cast between integer and bool #2370

Merged
merged 5 commits into from
May 10, 2022

Conversation

xiaoyong-z
Copy link
Contributor

@xiaoyong-z xiaoyong-z commented May 8, 2022

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:

  • Summarize your change (mandatory)
  • How does this PR work? Need a brief introduction for the changed logic (optional)
  • Describe clearly one logical change and avoid lazy messages (optional)
  • Describe any limitations of the current code (optional)

Checklist

- [ ] I have written necessary docs and comments

  • I have added necessary unit tests and integration tests

Refer to a related PR or issue link (optional)

#112

@CLAassistant
Copy link

CLAassistant commented May 8, 2022

CLA assistant check
All committers have signed the CLA.

@xiaoyong-z xiaoyong-z force-pushed the integer-bool-cast branch from 849a8d3 to 1c10265 Compare May 8, 2022 10:39
Copy link
Contributor

@xiangjinwu xiangjinwu left a 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:

Comment on lines 220 to 223
match input {
0 => Ok(false),
_ => Ok(true),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok(input != 0)

Comment on lines 105 to 110
{ 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 },
Copy link
Contributor

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.

@xiaoyong-z xiaoyong-z force-pushed the integer-bool-cast branch from 680689f to 3e9a075 Compare May 9, 2022 14:05
@xiaoyong-z xiaoyong-z requested a review from xiangjinwu May 9, 2022 15:50
Copy link
Contributor

@xiangjinwu xiangjinwu left a 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.

@xxchan xxchan enabled auto-merge (squash) May 10, 2022 21:11
@codecov
Copy link

codecov bot commented May 10, 2022

Codecov Report

Merging #2370 (856bc50) into main (04f0912) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #2370   +/-   ##
=======================================
  Coverage   71.26%   71.26%           
=======================================
  Files         688      688           
  Lines       86985    86995   +10     
=======================================
+ Hits        61987    61998   +11     
+ Misses      24998    24997    -1     
Flag Coverage Δ
rust 71.26% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/expr/src/expr/expr_unary.rs 75.72% <ø> (ø)
src/expr/src/vector_op/cast.rs 49.65% <100.00%> (+3.72%) ⬆️
src/meta/src/model/barrier.rs 82.14% <0.00%> (+3.57%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@xxchan xxchan merged commit a5311a7 into risingwavelabs:main May 10, 2022
@xiaoyong-z xiaoyong-z deleted the integer-bool-cast branch May 12, 2022 17:40
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.

5 participants