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

feat: Add linear regression aggregate functions #7211

Merged
merged 1 commit into from
Aug 8, 2023
Merged

Conversation

2010YOUY01
Copy link
Contributor

Which issue does this PR close?

NA

Rationale for this change

A previous PR first implemented regr_slope(y, x) linear regression aggregate function #7135
This PR wants to extend the previous one to implement all PostgreSQL's linear regression aggregate functions like regr_intercept(y, x)
https://www.postgresql.org/docs/9.4/functions-aggregate.html

What changes are included in this PR?

Extend RegrAccumulator to support other regr_*(y, x) aggregate functions

Are these changes tested?

All end-to-end tests have the same result compared to PostgreSQL

Are there any user-facing changes?

No

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Physical Expressions core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Aug 6, 2023
@2010YOUY01 2010YOUY01 changed the title Add regr_*() aggregate functions Add linear regression aggregate functions Aug 6, 2023
@alamb
Copy link
Contributor

alamb commented Aug 7, 2023

Thank you @2010YOUY01 -- this looks awesome. I plan to review it carefully tomorrow

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.

This looks great @2010YOUY01 -- thank you. I reviewed it carefully and I think the structure and comments are very nice and the documentation is 👌

Thank you for the contribution

Ok(ScalarValue::Float64(None))
} else {
Ok(ScalarValue::Float64(Some(cov_pop_x_y / var_pop_x)))
match self.regr_type {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

@alamb alamb merged commit d1361d5 into apache:main Aug 8, 2023
23 checks passed
@2010YOUY01 2010YOUY01 changed the title Add linear regression aggregate functions feat: Add linear regression aggregate functions Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions physical-expr Physical Expressions sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants