diff --git a/bigframes/session/executor.py b/bigframes/session/executor.py index 170f0ac086..a84861878a 100644 --- a/bigframes/session/executor.py +++ b/bigframes/session/executor.py @@ -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) try: query_job = self.bqclient.query(sql, job_config=job_config) return ( diff --git a/tests/system/small/test_series.py b/tests/system/small/test_series.py index b906f452b7..5bb20e2714 100644 --- a/tests/system/small/test_series.py +++ b/tests/system/small/test_series.py @@ -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 # 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()),