-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: DISTINCT bitwise and boolean aggregate functions
#6581
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
feat: DISTINCT bitwise and boolean aggregate functions
#6581
Conversation
alamb
left a comment
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.
Looks good to me @izveigor -- thank you ❤️ The only thing I think this PR needs is basic test SQL level coverage for distinct of the other bitwise aggregates
| ---- | ||
| 1632751011 5960911605712039654 148 54789 169634700 | ||
|
|
||
| # csv_query_bit_xor_distinct |
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.
| # csv_query_bit_xor_distinct | |
| # csv_query_bit_xor_distinct (should be different than above) |
| SELECT bit_xor(distinct c5 % 2) FROM aggregate_test_100 | ||
| ---- | ||
| -2 | ||
|
|
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.
even though, as you note,BIT_AND(DISTINCT), BIT_OR(DISTINCT), BOOL_AND(DISTINCT) and BOOL_OR(DISTINCT) are the same as their non distinct versions, I think we should still add SQL coverage so that we don't accidentally break the feature during some future refactoring
|
|
||
| /// Expression for a BIT_XOR(DISTINCT) aggregation. | ||
| #[derive(Debug, Clone)] | ||
| pub struct DistinctBitXor { |
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.
I wonder if it is possible to avoid duplicated code for distinct aggregates -- they are all basically doing the same thing 🤔
alamb
left a comment
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.
👍 thank you @izveigor
* feat: distinct bitwise and boolean aggregate functions * feat: add distinct sqllogictests for other bitwise and boolean aggregate functions * feat: improve docs for csv_query_bit_xor_distinct
Which issue does this PR close?
Follow on to #6276
Rationale for this change
We can use
BIT_AND(DISTINCT),BIT_OR(DISTINCT),BOOL_AND(DISTINCT)andBOOL_OR(DISTINCT)but it won't have any effect, so the mechanism of action remains the same. Another case isBIT_XOR(DISTINCT), for this function the results with the default version will be different.For example (where
a=[4, 7, 4, 7, 15]):What changes are included in this PR?
All bitwise and boolean aggregate functions start to support
DISTINCTcases.Are these changes tested?
Yes
Are there any user-facing changes?
Yes