-
Notifications
You must be signed in to change notification settings - Fork 706
feat: add single_value agg function #824
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
Codecov Report
@@ Coverage Diff @@
## main #824 +/- ##
============================================
+ Coverage 72.22% 72.24% +0.01%
Complexity 2766 2766
============================================
Files 923 923
Lines 53652 53700 +48
Branches 1787 1787
============================================
+ Hits 38752 38796 +44
- Misses 14010 14014 +4
Partials 890 890
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
| (None, _) => Ok(input), | ||
| (Some(_), None) => Ok(result), |
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.
Seems a column with [None, Some(2), None] would return Ok rather than Err? It is an error in pg.
btw, how does it work in 2-phase 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.
Good catch!
I believe these two mistakes that need to be corrected. Let me track both points in a new issue.
What's changed and what's your intention?
PLEASE DO NOT LEAVE THIS EMPTY !!!
This PR adds a special
single_valueaggregation function as defined in Calcite.Its appearance is due to scalar subquery. Scalar subquery, such as in
select .... from .... where column X = (select column Y from ......), should only return one row.
single_valueaggregation function would check whether the subquery indeed returns exactly one row. The different behaviors from general aggregation functions is:pub fn single_value<'a, T>(result: Option<T>, input: Option<T>) -> Option<T>now needs to return aresultas it cannot acceptSometwice.Based on the observation of PG, it does not really error when there is no row returned. So we don't need to change
output_concrete.Haven't added tests yet.
Checklist