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: rewrite ifnull and nvl as coalesce #14877

Merged
merged 7 commits into from
Mar 9, 2024
Merged

fix: rewrite ifnull and nvl as coalesce #14877

merged 7 commits into from
Mar 9, 2024

Conversation

PsiACE
Copy link
Member

@PsiACE PsiACE commented Mar 7, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

I think we can simply rewrite ifnull and nvl as coalesce to fix this problem.

I noticed that DuckDB does it this way.

image

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

PsiACE added 2 commits March 7, 2024 16:57
Signed-off-by: Chojan Shang <psiace@apache.org>
Signed-off-by: Chojan Shang <psiace@apache.org>
@PsiACE PsiACE requested review from sundy-li and andylokandy March 7, 2024 09:34
@PsiACE PsiACE changed the title fix(type_check): rewrite ifnull and nvl as coalesce fix: rewrite ifnull and nvl as coalesce Mar 7, 2024
@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label Mar 7, 2024
PsiACE added 2 commits March 7, 2024 17:55
Signed-off-by: Chojan Shang <psiace@apache.org>
Signed-off-by: Chojan Shang <psiace@apache.org>
@PsiACE PsiACE requested a review from sundy-li March 7, 2024 11:29
PsiACE added 2 commits March 7, 2024 19:50
Signed-off-by: Chojan Shang <psiace@apache.org>
Signed-off-by: Chojan Shang <psiace@apache.org>
@andylokandy
Copy link
Contributor

can coalesce resist rand() > 0.5?

@PsiACE
Copy link
Member Author

PsiACE commented Mar 7, 2024

can coalesce resist rand() > 0.5?

I tested another example, unfortunately, it cannot. I have examined the implementation of DuckDB and it also cannot.

@PsiACE
Copy link
Member Author

PsiACE commented Mar 8, 2024

This PR should be a relatively reasonable fix. Would you like to review it again? @sundy-li

@sundy-li sundy-li added this pull request to the merge queue Mar 9, 2024
Merged via the queue into main with commit eeaf97c Mar 9, 2024
73 checks passed
@sundy-li sundy-li deleted the fix-nvl branch March 9, 2024 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix this PR patches a bug in codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: The results of the NVL function may be incorrect
3 participants