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

Extract Aggregate, Sort, and Join to struct from AggregatePlan #1326

Merged

Conversation

matthewmturner
Copy link
Contributor

@matthewmturner matthewmturner commented Nov 17, 2021

Which issue does this PR close?

Closes #1303
Closes #1228

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the datafusion Changes in the datafusion crate label Nov 17, 2021
@xudong963
Copy link
Member

Thanks @matthewmturner !

@matthewmturner matthewmturner changed the title First updates for AggregatePlan Extract Aggregate, Sort, and Join to struct from AggregatePlan Nov 17, 2021
/// Aggregates its input based on a set of grouping and aggregate
/// expressions (e.g. SUM).
#[derive(Clone)]
pub struct AggregatePlan {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling this Aggregate would be more consistent with what has been refactored in other PRs.

Let me know when this PR is ready @matthewmturner

Thanks!

/// The schema description of the aggregate output
schema: DFSchemaRef,
},
// Aggregate {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the final version, we should remove these useless code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -289,7 +303,7 @@ impl LogicalPlan {
LogicalPlan::Projection { schema, .. } => schema,
LogicalPlan::Filter { input, .. } => input.schema(),
LogicalPlan::Window { schema, .. } => schema,
LogicalPlan::Aggregate { schema, .. } => schema,
LogicalPlan::Aggregate(aggregate) => &aggregate.schema,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alamb I have question about the code style, before refactor, we use the style

::Aggregate {filed1, filed2, field3,....}

Someone may use the style after refactor

Aggregate(agg) => 
agg.field1
agg.field2
agg.field3

How about make consistent with before?
In My pull requests #1325 #1322 #1311, I keep consistent and use this style.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liukun4515 sorry I missed this question -- my preference would be for the resulting code to be consistent

For example, always use

LogicalPlan::Aggregate(Aggregate { ... })

or

LogicalPlan::Aggregate(aggregate)

I don't have any particular preference personally about which to use as long as we are consistent

aggr_expr,
..
} => group_expr.iter().chain(aggr_expr.iter()).cloned().collect(),
LogicalPlan::Aggregate(aggregate) => aggregate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same opinion like above, if we keep consistent like before, we can make less changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please align the code style using

LogicalPlan::Aggregate(aggregate {
  field1,
  field2
})

@@ -20,8 +20,8 @@
use crate::error::Result;
use crate::execution::context::ExecutionProps;
use crate::logical_plan::{
col, DFField, DFSchema, Expr, ExprRewriter, ExpressionVisitor, LogicalPlan,
Recursion, RewriteRecursion,
col, plan::AggregatePlan, DFField, DFSchema, Expr, ExprRewriter, ExpressionVisitor,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can make the struct AggregatePlan pub in the logical plan package mod file

@alamb
Copy link
Contributor

alamb commented Nov 22, 2021

I think this PR is now the last remaining in the set for #1228 -- we are close now. @matthewmturner any chance you can rebase this PR and we can wrap up this item?

@matthewmturner
Copy link
Contributor Author

I think this PR is now the last remaining in the set for #1228 -- we are close now. @matthewmturner any chance you can rebase this PR and we can wrap up this item?

yes, sry for delay. i am working on it.

i am going to align to style recommended by @liukun4515

@liukun4515
Copy link
Contributor

I think this PR is now the last remaining in the set for #1228 -- we are close now. @matthewmturner any chance you can rebase this PR and we can wrap up this item?

yes, sry for delay. i am working on it.

i am going to align to style recommended by @liukun4515

If your pull request is ready, I will review it.
@matthewmturner

@matthewmturner matthewmturner marked this pull request as ready for review November 23, 2021 02:31
@matthewmturner
Copy link
Contributor Author

@liukun4515 ready for review!

Copy link
Contributor

@liukun4515 liukun4515 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, if you address the code style comments.
@matthewmturner

@xudong963
Copy link
Member

LGTM, thanks @matthewmturner. You are the terminator of #1228 ! 🎉

Copy link
Member

@houqp houqp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@houqp houqp added the api change Changes the API exposed to users of the crate label Nov 23, 2021
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great -- thank you @matthewmturner @liukun4515 and @xudong963 for driving this refactoring

@alamb alamb merged commit 66f5d19 into apache:master Nov 23, 2021
@alamb alamb removed the api change Changes the API exposed to users of the crate label Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate
Projects
None yet
5 participants