-
Notifications
You must be signed in to change notification settings - Fork 392
feat: Add global agg support for Dataframe select
#6067
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
base: main
Are you sure you want to change the base?
feat: Add global agg support for Dataframe select
#6067
Conversation
Greptile SummaryThis PR enables global aggregations in Key Changes:
Test Coverage:
Minor Issues Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant LogicalPlanBuilder
participant ExprResolver
participant has_agg
participant Aggregate
participant Project
User->>LogicalPlanBuilder: select([col('a').sum().alias('sum_a')])
LogicalPlanBuilder->>ExprResolver: resolve(to_select)
ExprResolver-->>LogicalPlanBuilder: resolved expressions
LogicalPlanBuilder->>has_agg: check if any expr has aggregation
has_agg-->>LogicalPlanBuilder: true
Note over LogicalPlanBuilder: Split expressions into agg and foldable
loop For each expression
alt Expression has aggregation
LogicalPlanBuilder->>LogicalPlanBuilder: Validate top-level Agg only
LogicalPlanBuilder->>LogicalPlanBuilder: Add to agg_exprs
else Expression is non-agg
LogicalPlanBuilder->>ExprResolver: Validate with empty groupby
LogicalPlanBuilder->>LogicalPlanBuilder: Check requires_computation
alt Is foldable literal
LogicalPlanBuilder->>LogicalPlanBuilder: Add to foldable_exprs
else Requires computation
LogicalPlanBuilder-->>User: Error: Expected aggregation
end
end
end
Note over LogicalPlanBuilder: Build internal aggregate plan
loop For each agg expression
LogicalPlanBuilder->>LogicalPlanBuilder: Compute semantic_id
LogicalPlanBuilder->>LogicalPlanBuilder: Create internal agg (semantic_id alias)
LogicalPlanBuilder->>LogicalPlanBuilder: Create final expr (user name alias)
end
LogicalPlanBuilder->>Aggregate: try_new(agg_internal, empty groupby)
Aggregate-->>LogicalPlanBuilder: agg_plan
LogicalPlanBuilder->>LogicalPlanBuilder: Extend final_exprs with foldable_exprs
LogicalPlanBuilder->>Project: try_new(agg_plan, final_exprs)
Project-->>LogicalPlanBuilder: logical_plan
LogicalPlanBuilder-->>User: Updated plan (Aggregate -> Project)
|
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.
2 files reviewed, 2 comments
1ad115c to
ede725e
Compare
|
Gently ping @colin-ho @kevinzwang please help review this PR when you are free. Thank you for your time. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6067 +/- ##
==========================================
- Coverage 72.91% 72.91% -0.01%
==========================================
Files 973 973
Lines 126166 126243 +77
==========================================
+ Hits 91995 92044 +49
- Misses 34171 34199 +28
🚀 New features to boost your workflow:
|
|
Hi @universalmind303 please help review this pr if you are free. Thank you for your time and sorry if this is jumping the gun. |
Changes Made
We encountered an issue about aggregate functions are not permitted in the SELECT statement unless a GROUP BY clause is specified.
for example:
This issue has been resolved in daft sql #2799, but it is still not supported in dataframe. This PR is precisely aimed at addressing this issue.
Related Issues
I found that a related issue already exists. #1979