Skip to content

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

Merged
jayzhan211 merged 5 commits into
apache:mainfrom
jayzhan211:rm-sum-v3
Jun 8, 2024
Merged

Remove expr_fn::sum and replace them with function stub#10816
jayzhan211 merged 5 commits into
apache:mainfrom
jayzhan211:rm-sum-v3

Conversation

@jayzhan211

@jayzhan211jayzhan211 commented Jun 7, 2024

Copy link
Copy Markdown
Contributor

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 <jayzhan211@gmail.com>
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

@jayzhan211jayzhan211Jun 7, 2024

Copy link
Copy Markdown
ContributorAuthor

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 <jayzhan211@gmail.com>
@github-actionsgithub-actionsBot added logical-expr Logical plan and expressions optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) labels Jun 7, 2024
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

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

Comment threaddatafusion/optimizer/src/test/function_stub.rs
}

#[derive(Debug)]
pub struct Sum {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
pubstructSum{
/// Stub `sum` used for optimizer testing
pubstructSum{

@alamb

alamb commented Jun 7, 2024

Copy link
Copy Markdown
Contributor

Thank you @jayzhan211

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@jayzhan211
jayzhan211 marked this pull request as ready for review June 7, 2024 12:27
@jayzhan211
jayzhan211 requested a review from alambJune 7, 2024 12:27

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

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


/// 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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉

@jayzhan211

Copy link
Copy Markdown
ContributorAuthor

Thanks @alamb

@jayzhan211
jayzhan211 merged commit e3af174 into apache:mainJun 8, 2024
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
* introduce stub for test
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* fix err msg
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* dont compare error msg, ci is not consistent with local
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* comment and cli update
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
* fmt
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
---------
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-exprLogical plan and expressionsoptimizerOptimizer rulessqllogictestSQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jayzhan211@alamb