Add note about NULL handling in BIT_COUNT function - #10352
Add note about NULL handling in BIT_COUNT function#10352Steve Jones (way0utwest) wants to merge 2 commits into
Conversation
Clarified behavior of BIT_COUNT with NULL values.
|
Steve Jones (@way0utwest) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change. |
1 similar comment
|
Steve Jones (@way0utwest) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change. |
|
Learn Build status updates of commit aa8de06: ✅ Validation status: passed
For more details, please refer to the build report. |
|
Can you review the proposed changes? IMPORTANT: When the changes are ready for publication, adding a #label:"aq-pr-triaged" |
There was a problem hiding this comment.
Pull request overview
Clarifies the documented behavior of BIT_COUNT when the input expression is NULL, ensuring readers understand the function’s null-propagation behavior.
Changes:
- Added a note stating that
BIT_COUNTreturnsNULLwhen passed aNULLexpression.
|
Learn Build status updates of commit 93195ff: ✅ Validation status: passed
For more details, please refer to the build report. |
|
|
||
| For example, `SELECT BIT_COUNT (CAST (-1 AS SMALLINT))` and `SELECT BIT_COUNT (CAST (-1 AS INT))` return `16` and `32` respectively. This is intended, as the binary representation of `-1` can have a different number of bits set to `1` depending on the data type. | ||
|
|
||
| If *expression_value* is `NULL`, `BIT_COUNT` returns `NULL`. |
There was a problem hiding this comment.
I would suggest something like:
If expression_value is NULL of a supported data type, BIT_COUNT returns NULL. An untyped NULL literal isn't a valid argument; cast it to a supported type.
For example:
SELECT BIT_COUNT(CAST(NULL AS int)); -- Returns NULLThere was a problem hiding this comment.
Thanks Derek. I'll pull this into an internal PR.
Clarified behavior of BIT_COUNT with NULL values.