handle 0 and NULL value of NTH_VALUE function#12676
Merged
comphead merged 3 commits intoapache:mainfrom Oct 1, 2024
Merged
Conversation
comphead
reviewed
Sep 30, 2024
comphead
approved these changes
Oct 1, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #12320.
Rationale for this change
The root cause in #12320 is because
get_signed_integer_valuewill return an error onNULLorInt64(NULL)value. To process thenth_valuefunction, it requires thenvalue should be an integer. Therefore, I decided to convertNULLvalue to 0 inget_signed_integer_valueand implement handler for the0case. This will evaluate to NULL value for thenth_value(v1, NULL)expression.Furthermore, it also evaluate the
nth_value(v1, 0)to NULL instead of generating panic, which match the expected behaviour in duckdb.What changes are included in this PR?
[x] Return 0 for NULL value in
get_signed_integer[x] Handle nth_value execution when n is 0
[x] Test file updated to test
nth_value(v2, 0),nth_value(v2, NULL)andnth_value(v2, v2 * NULL).Are these changes tested?
Yes
Are there any user-facing changes?