-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
builtins: support bit_count for bytea and varbit #115273
Conversation
Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR. My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
05d9b50
to
8a884c6
Compare
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 your contribution!
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @andrew-delph and @michae2)
pkg/sql/sem/builtins/builtins.go
line 243 at r1 (raw file):
"bit_count": makeBuiltin(tree.FunctionProperties{Category: builtinconstants.CategoryString}, stringOverload1(
could you say more about why you added a string overload? it does not appear that postgres has one. i don't understand how it's expected to work on an input like: bit_count('abc')
pkg/sql/sem/builtins/builtins.go
line 259 at r1 (raw file):
total := 0 for _, b := range s { total += bits.OnesCount(uint(b))
nit: should this be bits.OnesCount32(uint32(b))
, since iterating over a string always returns int32
s (which are aliased to rune
s)?
pkg/sql/sem/eval/testdata/eval/builtins
line 102 at r1 (raw file):
eval bit_count('1111111111'::bit(10))
can you also add testing for the bytea
overload?
66aea14
to
450a394
Compare
@rafiss Thank you for your comments.
|
450a394
to
3723f58
Compare
Fixes: cockroachdb#114817 Release note (sql change): Added the bit_count builtin function for BIT and BYTEA types.
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.
this lgtm! thank you for your contribution
bors r+
Build succeeded: |
Fixes: #114817
Release note (sql change): Added the bit_count builtin function
for BIT and BYTEA types.