Skip to content

refactor: generalize aggregation to handle 0,1, or 2 inputs #360

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 10 commits into from
Feb 5, 2024

Conversation

TrevorBergeron
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Jan 29, 2024
@TrevorBergeron TrevorBergeron marked this pull request as ready for review January 29, 2024 23:46
@TrevorBergeron TrevorBergeron requested review from a team as code owners January 29, 2024 23:46
@TrevorBergeron TrevorBergeron requested a review from tswast January 29, 2024 23:46
) -> ibis_types.Value:
return compile_agg(op, input)
if isinstance(aggregate, ex.UnaryAggregation):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note to self: Is there another class for 0 argument aggregations (e.g. row count) that we need to handle here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CL title is a lie, I haven't actually defined the 0-arg aggregation ops yet. They still pretend to be 1-arg aggregations. Will convert 0-arg ops (rank is another one) in a follow-up pr.

@@ -382,6 +418,19 @@ def _(
)


@compile_binary_agg.register
def _(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a change introduced in this PR, but it's a bit odd to see functions with name _ outside of a closure function. Even though the name isn't really relevant, as we're relying on type-based dispatching, I'd expect more than a 1-character name.

https://google.github.io/styleguide/pyguide.html#3161-names-to-avoid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code examples for @singledispatch in https://docs.python.org/3/library/functools.html use the _ naming for overrides. Also the linter wants unique name for each implementation if it is not _. I can change though if this goes against our style guidelines.

@TrevorBergeron TrevorBergeron added the automerge Merge the pull request once unit tests and other checks pass. label Feb 5, 2024
@gcf-merge-on-green gcf-merge-on-green bot merged commit 93835ef into main Feb 5, 2024
@gcf-merge-on-green gcf-merge-on-green bot deleted the corr_as_agg branch February 5, 2024 22:40
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants