Skip to content

[Bug] Fix the bug of nullif function:#5882

Merged
morningman merged 1 commit intoapache:masterfrom
HappenLee:view_bug
May 26, 2021
Merged

[Bug] Fix the bug of nullif function:#5882
morningman merged 1 commit intoapache:masterfrom
HappenLee:view_bug

Conversation

@HappenLee
Copy link
Contributor

Proposed changes

  1. Prevent return NULL call nullif(98, null) in FE
  2. Support DecimalV2 of nullif function to get the right result

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Code refactor (Modify the code structure, format the code, etc...)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have created an issue on (Fix [BUG] NULLIF() function result is wrong #5858) and described the bug/feature there in detail
  • Compiling and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • If these changes need document changes, I have updated the document
  • Any dependent changes have been merged

1. Prevent return NULL call nullif(98, null) in FE
2. Support DecimalV2 of nullif function to get the right result
@EmmyMiao87 EmmyMiao87 added area/sql/execution Issues or PRs related to the execution engine area/sql/function Issues or PRs related to the SQL functions kind/fix Categorizes issue or PR as related to a bug. labels May 24, 2021
Copy link
Contributor

@EmmyMiao87 EmmyMiao87 left a comment

Choose a reason for hiding this comment

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

what if SELECT ALL NULLIF (-98, NULL) AS col0 ?

@HappenLee
Copy link
Contributor Author

what if SELECT ALL NULLIF (-98, NULL) AS col0 ?

The right result of nullif(-98, null) is -98. but before fix the bug, the answer is null. Because the FE wiil treat all the function not in non_null_result_with_null_param_functions alwalys null if there params have null.

so add the nullif function to non_null_result_with_null_param_functions we can get the right answer:98

@EmmyMiao87
Copy link
Contributor

non_null_result_with_null_param_functions

Great

Copy link
Contributor

@EmmyMiao87 EmmyMiao87 left a comment

Choose a reason for hiding this comment

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

LGTM

@EmmyMiao87 EmmyMiao87 added the approved Indicates a PR has been approved by one committer. label May 24, 2021
@EmmyMiao87 EmmyMiao87 self-assigned this May 24, 2021
@morningman morningman merged commit 629e440 into apache:master May 26, 2021
stdpain pushed a commit to stdpain/incubator-doris that referenced this pull request Jul 8, 2021
1. Prevent return NULL call nullif(98, null) in FE
2. Support DecimalV2 of nullif function to get the right result
w41ter pushed a commit to w41ter/incubator-doris that referenced this pull request Dec 26, 2025
…ed correctly (apache#5882)

## Proposed changes

Issue Number: close CIR-18533

<!--Describe your changes.-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/sql/execution Issues or PRs related to the execution engine area/sql/function Issues or PRs related to the SQL functions kind/fix Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] NULLIF() function result is wrong

3 participants

Comments