Skip to content
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

Support for BOOLOR_AGG, BOOLXOR_AGG, BOOLAND_AGG aggregate function #22949

Closed
rcauble opened this issue May 7, 2023 · 7 comments
Closed

Support for BOOLOR_AGG, BOOLXOR_AGG, BOOLAND_AGG aggregate function #22949

rcauble opened this issue May 7, 2023 · 7 comments

Comments

@rcauble
Copy link

rcauble commented May 7, 2023

Feature request

Is your feature request related to a problem? Please describe.
We currently have cases where we need to perform a logical OR aggregation over a boolean column. We currently do this like this

SELECT COUNT(CASE WHEN BOOLEAN_COL THEN 1 ELSE NULL) > 0

If there were a BOOL_OR, it would be potentially more optimal since it would allow the aggregation to short-circuit, stopping aggregation as soon as it observes a single TRUE

Describe the solution you'd like
A BOOL_OR aggregation that matches Vertica's BOOL_OR aggregation
https://www.vertica.com/docs/9.3.x/HTML/Content/Authoring/SQLReferenceManual/Functions/Aggregate/BOOLORAggregate.htm?tocpath=SQL%20Reference%20Manual%7CSQL%20Functions%7CAggregate%20Functions%7C_____12

Describe alternatives you've considered
The SELECT COUNT CASE WHEN > 1 that I mention above. It works but possibly sub-optimal.

Additional context

@wangsimo0
Copy link
Contributor

Thanks for the proposal! Because this is an aggregate function, so I suggest it is better named boolor_agg. This is a relatively standard function that supported by many database systems, and the design is clear. For example:

https://docs.snowflake.com/en/sql-reference/functions/boolor_agg
https://docs.databricks.com/sql/language-manual/functions/bool_or.html

also it will be great if starrocks can support boolxor_agg, booland_agg.

@wangsimo0 wangsimo0 changed the title Support for BOOL_OR aggregate function Support for BOOLOR_AGG, BOOLXOR_AGG, BOOLAND_AGG aggregate function May 26, 2023
@rcauble
Copy link
Author

rcauble commented May 26, 2023

If they can use the same function names as in vertica it makes portability slightly easier since the same SQL will execute in both vertica and starrocks. No big deal either way since we have a dialect abstraction in our code.

@zhangruchubaba
Copy link
Contributor

@kateshaowanjou If no one has claimed this task yet, I'll try it

@wangsimo0
Copy link
Contributor

@zhangruchubaba hi buddy hows everything going? :)

@zhangruchubaba
Copy link
Contributor

@zhangruchubaba hi buddy hows everything going? :)

yeah! work in progress

Copy link

We have marked this issue as stale because it has been inactive for 6 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to StarRocks!

@jaingmengmeng
Copy link

jaingmengmeng commented May 23, 2024

@wangsimo0 If no one has claimed this task yet, I'll try it.

This is not closed. I've changed the assignee to you. If you have any questions we can discuss them via IM if you prefer:
https://853921.ma3you.cn/articles/b12e90J/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants