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

Remove expr_fn::sum and replace them with function stub #10816

Merged
merged 5 commits into from
Jun 8, 2024

Conversation

jayzhan211
Copy link
Contributor

@jayzhan211 jayzhan211 commented Jun 7, 2024

Which issue does this PR close?

Part of #10731
Inspired from #10807 (comment)
Close #10807

Rationale for this change

The reason to add a stub is that as we pull the aggregate functions out of the core and into datafusion-functions-aggregate the existing optimizer passes don't depend on datafusion-functions-aggregate.

Thus by using stubs we'll keep the optimizer passes decoupled from the built in aggregate functions as much as possible.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

Signed-off-by: jayzhan211 <[email protected]>
@@ -5334,3 +5334,34 @@ physical_plan
03)----AggregateExec: mode=Partial, gby=[], aggr=[first_value(convert_first_last_table.c1) ORDER BY [convert_first_last_table.c2 DESC NULLS FIRST]]
04)------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
05)--------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/convert_first_last.csv]]}, projection=[c1, c2], output_orderings=[[c1@0 ASC NULLS LAST], [c2@1 DESC]], has_header=true

# test building plan with aggreagte sum
Copy link
Contributor Author

@jayzhan211 jayzhan211 Jun 7, 2024

Choose a reason for hiding this comment

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

move the corresponding test in datafusion_expr to avoid introducing another stub

Signed-off-by: jayzhan211 <[email protected]>
@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) labels Jun 7, 2024
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.

I think this looks good, fwiw

}

#[derive(Debug)]
pub struct Sum {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub struct Sum {
/// Stub `sum` used for optimizer testing
pub struct Sum {

@alamb
Copy link
Contributor

alamb commented Jun 7, 2024

Thank you @jayzhan211

Signed-off-by: jayzhan211 <[email protected]>
Signed-off-by: jayzhan211 <[email protected]>
@jayzhan211 jayzhan211 marked this pull request as ready for review June 7, 2024 12:27
@jayzhan211 jayzhan211 requested a review from alamb June 7, 2024 12:27
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.

Thank you @jayzhan211 -- this looks great to me

I also updated this PR's description to add some additional rationale

@@ -168,20 +168,6 @@ pub fn max(expr: Expr) -> Expr {
))
}

/// Create an expression to represent the sum() aggregate function
///
/// TODO: Remove this function and use `sum` from `datafusion_functions_aggregate::expr_fn` instead
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

@jayzhan211
Copy link
Contributor Author

Thanks @alamb

@jayzhan211 jayzhan211 merged commit e3af174 into apache:main Jun 8, 2024
26 checks passed
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
* introduce stub for test

Signed-off-by: jayzhan211 <[email protected]>

* fix err msg

Signed-off-by: jayzhan211 <[email protected]>

* dont compare error msg, ci is not consistent with local

Signed-off-by: jayzhan211 <[email protected]>

* comment and cli update

Signed-off-by: jayzhan211 <[email protected]>

* fmt

Signed-off-by: jayzhan211 <[email protected]>

---------

Signed-off-by: jayzhan211 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants