Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: unordered mode too many labels issue. #1148

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions 5 bigframes/session/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,12 @@ def _run_execute_query(
job_config.maximum_bytes_billed = (
bigframes.options.compute.maximum_bytes_billed
)
# Note: add_labels is global scope which may have unexpected effects
bq_io.add_labels(job_config, api_name=api_name)

if not self.strictly_ordered:
job_config.labels["bigframes-mode"] = "unordered"

# Note: add_labels is global scope which may have unexpected effects
bq_io.add_labels(job_config, api_name=api_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Highly recommend adding a test using the customer's use case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

try:
query_job = self.bqclient.query(sql, job_config=job_config)
return (
Expand Down
31 changes: 18 additions & 13 deletions 31 tests/system/small/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2768,20 +2768,25 @@ def test_series_case_when(scalars_dfs_maybe_ordered):

# TODO(tswast): pandas case_when appears to assume True when a value is
Copy link
Contributor

@shobsi shobsi Nov 12, 2024

Choose a reason for hiding this comment

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

I would keep this comment, or rather add a dedicated test that clearly conveys the intent - test_series_case_when_with_large_number_of_operations, or even test_series_large_number_of_operations, with comment that describes the labels limit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to have all cases in the original test. Keep only one test can be overall faster I think.

# null. I suspect this should be considered a bug in pandas.
bf_result = bf_series.case_when(
[
((bf_series > 100).fillna(True), bf_series - 1),
((bf_series > 0).fillna(True), pd.NA),
((bf_series < -100).fillna(True), -1000),
]
).to_pandas()
pd_result = pd_series.case_when(
[
(pd_series > 100, pd_series - 1),
(pd_series > 0, pd.NA),
(pd_series < -100, -1000),
]

# Generate 150 conditions to test case_when with a large number of conditions
bf_conditions = (
[((bf_series > 645).fillna(True), bf_series - 1)]
+ [((bf_series > (-100 + i * 5)).fillna(True), i) for i in range(148, 0, -1)]
+ [((bf_series <= -100).fillna(True), pd.NA)]
)

pd_conditions = (
[((pd_series > 645), pd_series - 1)]
+ [((pd_series > (-100 + i * 5)), i) for i in range(148, 0, -1)]
+ [(pd_series <= -100, pd.NA)]
)

assert len(bf_conditions) == 150

bf_result = bf_series.case_when(bf_conditions).to_pandas()
pd_result = pd_series.case_when(pd_conditions)

pd.testing.assert_series_equal(
bf_result,
pd_result.astype(pd.Int64Dtype()),
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.