-
Couldn't load subscription status.
- Fork 1.7k
Fix the null handling for to_char function #14908
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
LGTM |
| } | ||
|
|
||
| #[test] | ||
| fn test_to_char_input_none_scalar() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need rust test for this function, we can add it to slt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting this.
Removed.
|
Thanks @kosiew and @jayzhan211 |
…apache#14970) * revert _to_char_scalar to before apache#14908 * Amend formatted loop - handle null * revert _to_char_array to before apache#14908 * add slt test
Which issue does this PR close?
to_charfunction #14884.Rationale for this change
Currently, when passing a NULL value to to_char, it returns an empty string instead of NULL. This behavior differs from PostgreSQL, Spark, DuckDb, which returns NULL when given a NULL input. Aligning with common practise ensures consistency and expected behavior for users relying on SQL standards.
What changes are included in this PR?
Modify to_char function implementation to return NULL when the input is NULL.
Update relevant test cases to validate the correct behavior.
Ensure consistent behavior across different data types.
Are these changes tested?
Yes, test cases have been added to check the NULL behavior of to_char.
Existing test cases have been updated where necessary.
Verified that the changes do not introduce regressions.
Are there any user-facing changes?
Users who previously received an empty string when calling to_char(NULL, format) will now receive NULL, aligning with PostgreSQL behavior.
No breaking changes to public APIs, but behavior will be corrected to match expected SQL standards.