-
-
Notifications
You must be signed in to change notification settings - Fork 262
Add support bitwise aggregate functions #8768
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
|
This is related to #8175 In MySQL and PostgreSQL, these functions are called |
| <bin_or agg> ::= BIN_OR_AGG(<expression>) | ||
| <bin_xor agg> ::= BIN_XOR_AGG([ALL | DISTINCT] <expression>) |
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.
What is a real use case for BIN_XOR_AGG?
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.
Personally, BIN_AND_AGG and BIN_OR_AGG would have been enough for me. But since MySQL and PostgreSQL have BIT_XOR, I decided to add a similar function to Firebird.
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.
Aggregate XOR could be used for some trivial hashing (dangerous but fast). Or (probably more useful) for combining multiple already calculated hashes -- e.g. every row is hashed independently and then row hashes are aggregated using XOR.
|
Thanks for the review. I'll fix it. |
The
BIN_AND_AGG,BIN_OR_AGG, andBIN_XOR_AGGaggregate functions perform bit operations.NULLsare ignored. It's returned only in the case of none evaluated records having a non-null value.The input argument must be one of the integer types (
SMALLINT,INTEGER,BIGINT, orINT128).The output result is of the same type as the input argument.
Syntax:
The
BIN_AND_AGGandBIN_OR_AGGfunctions do not support theDISTINCTkeyword, since eliminating duplicates doesnot affect the result. However, for
BIN_XOR_AGG, you can specifyDISTINCTto exclude duplicates from processing.Example: