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: implement nullif and coalesce function #2308

Merged
merged 21 commits into from
May 6, 2022
Merged

Conversation

cykbls01
Copy link
Contributor

@cykbls01 cykbls01 commented May 4, 2022

What's changed and what's your intention?

PLEASE DO NOT LEAVE THIS EMPTY !!!

  1. implement nullif function.
select nullif(expr1,expr2)
  1. implement coalesce function.
select coalesce(expr1,expr2,expr3...)

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)

#2283
#2284

@codecov
Copy link

codecov bot commented May 4, 2022

Codecov Report

Merging #2308 (8adafb1) into main (151a2cf) will increase coverage by 0.03%.
The diff coverage is 90.90%.

@@            Coverage Diff             @@
##             main    #2308      +/-   ##
==========================================
+ Coverage   71.02%   71.05%   +0.03%     
==========================================
  Files         676      677       +1     
  Lines       84568    84696     +128     
==========================================
+ Hits        60064    60181     +117     
- Misses      24504    24515      +11     
Flag Coverage Δ
rust 71.05% <90.90%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
src/common/src/types/mod.rs 63.65% <0.00%> (-0.76%) ⬇️
src/expr/src/expr/mod.rs 48.83% <0.00%> (-1.17%) ⬇️
src/expr/src/expr/expr_coalesce.rs 95.18% <95.18%> (ø)
src/expr/src/expr/expr_case.rs 98.21% <100.00%> (+0.04%) ⬆️
src/frontend/src/binder/expr/function.rs 92.42% <100.00%> (+2.62%) ⬆️
src/frontend/src/expr/function_call.rs 99.25% <100.00%> (+<0.01%) ⬆️

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

@cykbls01 cykbls01 changed the title feat: implement nullif function feat: implement nullif and coalesce function May 5, 2022
Copy link
Contributor

@neverchanje neverchanje left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -80,6 +88,44 @@ impl Binder {
}
}

/// Make sure inputs only have 2 value and rewrite the arguments.
/// Nullif(expr1,expr2) -> Case(Equal(expr1 = expr2),null,expr1).
fn write_nullif_to_case_args(inputs: Vec<ExprImpl>) -> Result<Vec<ExprImpl>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fn write_nullif_to_case_args(inputs: Vec<ExprImpl>) -> Result<Vec<ExprImpl>> {
fn rewrite_nullif_to_case_when(inputs: Vec<ExprImpl>) -> Result<Vec<ExprImpl>> {

@neverchanje neverchanje marked this pull request as ready for review May 6, 2022 10:30
@cykbls01 cykbls01 merged commit 568742a into main May 6, 2022
@cykbls01 cykbls01 deleted the feat/nullif_and_coalesce branch May 6, 2022 11:55
@neverchanje neverchanje added the user-facing-changes Contains changes that are visible to users label May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants