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

[Bug]: Tests failing when trying to use the right logic for categoricals in Pandas #28637

Closed
1 of 15 tasks
caneff opened this issue Sep 24, 2023 · 4 comments
Closed
1 of 15 tasks
Labels
bug dataframe done & done Issue has been reviewed after it was closed for verification, followups, etc. P3 python

Comments

@caneff
Copy link
Contributor

caneff commented Sep 24, 2023

What happened?

In #28623 I tried to update the categorical checks to the non-deprecated way dictated by pandas, but when I do I get failing tests. It makes frames_test.py::DeferredFrameTest::test_categorical_groupby fail for AssertionError: NonParallelOperation not raised.

Getting rid of the nonparallel=True option in those tests fails with

E       AssertionError: Expression does not preserve partitioning!
E                       Expression: ComputedExpression[post_combine_sum_DataFrame_140482246047888]
E                       Requires: Index
E                       Preserves: Arbitrary
E                       Input partitioning: Index
E                       Expected output partitioning: Index

Issue Priority

Priority: 2

Issue Components

  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam examples
  • Component: Beam playground
  • Component: Beam katas
  • Component: Website
  • Component: Spark Runner
  • Component: Flink Runner
  • Component: Samza Runner
  • Component: Twister2 Runner
  • Component: Hazelcast Jet Runner
  • Component: Google Cloud Dataflow Runner
@caneff
Copy link
Contributor Author

caneff commented Sep 24, 2023

R: @tvalentyn

@robertwb
Copy link
Contributor

The problem here is that the replacement for the deprecated method should be isinstance(to_group.get_level_values(i).dtype, pd.CategoricalDtype) rather than isinstance(to_group.get_level_values(i), pd.CategoricalDtype).

Without the correct detection that the columns are categorical this test doesn't attempt to do this as a non-parallel operation (hence the failure to raise the NonParallelOperation error) and gets the wrong result (due to duplicate default values when partitioned, as per BEAM-11190, which the categorical-column detection was put in place to resolve).

Checking the type of the column's dtype should solve the issue.

@caneff
Copy link
Contributor Author

caneff commented Oct 3, 2023

Yep that fixes it. Thanks!

@caneff caneff closed this as completed Oct 3, 2023
@github-actions github-actions bot added this to the 2.52.0 Release milestone Oct 3, 2023
@tvalentyn
Copy link
Contributor

Yep that fixes it. Thanks!

should we keep this open until we merge a fix?

@tvalentyn tvalentyn added the done & done Issue has been reviewed after it was closed for verification, followups, etc. label Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dataframe done & done Issue has been reviewed after it was closed for verification, followups, etc. P3 python
Projects
None yet
Development

No branches or pull requests

3 participants