Skip to content

feat(sql): eliminate extra group by scalars #9708

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

Merged
merged 4 commits into from
Jan 23, 2023

Conversation

sundy-li
Copy link
Member

@sundy-li sundy-li commented Jan 22, 2023

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Summary about this PR

eliminate extra group-by scalars

continue #9678
Closes #9611

@sundy-li sundy-li requested a review from leiysky January 22, 2023 15:54
@vercel
Copy link

vercel bot commented Jan 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
databend ⬜️ Ignored (Inspect) Jan 23, 2023 at 7:25AM (UTC)

@sundy-li sundy-li requested a review from andylokandy January 22, 2023 15:54
@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Jan 22, 2023
@BohuTANG
Copy link
Member

Run cargo fmt --all -- --check
Diff in /workspace/src/query/sql/src/planner/binder/aggregate.rs at line 327:
             } = expr
             {
                 let (scalar, alias) = Self::resolve_index_item(expr, *index, select_list)?;
-                
+
                 // If group by scalar is a constant literal, we can skip it.
                 if matches!(scalar, ScalarExpr::ConstantExpr(_)) {
                     continue;
Diff in /workspace/src/query/sql/src/planner/binder/aggregate.rs at line 334:
                 }
-                
+
                 let key = format!("{:?}", &scalar);
                 if let Entry::Vacant(entry) = bind_context.aggregate_info.group_items_map.entry(key)
                 {
Diff in /workspace/src/query/sql/src/planner/binder/select.rs at line 101:
             .await?;
 
         let (mut scalar_items, projections) = self.analyze_projection(&select_list)?;
-        
+
         // This will potentially add some alias group items to `from_context` if find some.
         self.analyze_group_items(&mut from_context, &select_list, &stmt.group_by)
             .await?;
Diff in /workspace/src/query/sql/src/planner/binder/select.rs at line 127:
             )
             .await?;
 
-        if !from_context.aggregate_info.aggregate_functions.is_empty() || !from_context.aggregate_info.group_items.is_empty()
+        if !from_context.aggregate_info.aggregate_functions.is_empty()
+            || !from_context.aggregate_info.group_items.is_empty()
         {
             s_expr = self.bind_aggregate(&mut from_context, s_expr).await?;
         }

@sundy-li sundy-li changed the title feat(sql): remove constant group by feat(sql): eliminate extra group by scalars Jan 23, 2023
@BohuTANG BohuTANG merged commit 99f59c4 into databendlabs:main Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Add rule_eliminate_groupby
2 participants