@@ -163,11 +163,11 @@ def test_df_construct_from_dict():
163163 )
164164
165165
166- def test_df_construct_inline_respects_location ():
166+ def test_df_construct_inline_respects_location (reset_default_session_and_location ):
167167 # Note: This starts a thread-local session.
168168 with bpd .option_context ("bigquery.location" , "europe-west1" ):
169169 df = bpd .DataFrame ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
170- repr ( df )
170+ df . to_gbq ( )
171171 assert df .query_job is not None
172172 table = bpd .get_global_session ().bqclient .get_table (df .query_job .destination )
173173
@@ -666,7 +666,8 @@ def test_df_peek(scalars_dfs_maybe_ordered):
666666
667667 session = scalars_df ._block .session
668668 slot_millis_sum = session .slot_millis_sum
669- peek_result = scalars_df .peek (n = 3 , force = False )
669+ # allow_large_results=False needed to get slot_millis_sum statistics only
670+ peek_result = scalars_df .peek (n = 3 , force = False , allow_large_results = True )
670671
671672 assert session .slot_millis_sum - slot_millis_sum > 1000
672673 pd .testing .assert_index_equal (scalars_pandas_df .columns , peek_result .columns )
@@ -4584,12 +4585,13 @@ def test_df_drop_duplicates(scalars_df_index, scalars_pandas_df_index, keep, sub
45844585 ],
45854586)
45864587def test_df_drop_duplicates_w_json (json_df , keep ):
4587- bf_df = json_df .drop_duplicates (keep = keep ).to_pandas ()
4588+ bf_df = json_df .drop_duplicates (keep = keep ).to_pandas (allow_large_results = True )
45884589
45894590 # drop_duplicates relies on pa.compute.dictionary_encode, which is incompatible
45904591 # with Arrow string extension types. Temporary conversion to standard Pandas
45914592 # strings is required.
4592- json_pandas_df = json_df .to_pandas ()
4593+ # allow_large_results=True for b/401630655
4594+ json_pandas_df = json_df .to_pandas (allow_large_results = True )
45934595 json_pandas_df ["json_col" ] = json_pandas_df ["json_col" ].astype (
45944596 pd .StringDtype (storage = "pyarrow" )
45954597 )
@@ -4951,14 +4953,16 @@ def test_df_bool_interpretation_error(scalars_df_index):
49514953
49524954
49534955def test_query_job_setters (scalars_df_default_index : dataframe .DataFrame ):
4954- job_ids = set ()
4955- repr (scalars_df_default_index )
4956- assert scalars_df_default_index .query_job is not None
4957- job_ids .add (scalars_df_default_index .query_job .job_id )
4958- scalars_df_default_index .to_pandas ()
4959- job_ids .add (scalars_df_default_index .query_job .job_id )
4956+ # if allow_large_results=False, might not create query job
4957+ with bigframes .option_context ("bigquery.allow_large_results" , True ):
4958+ job_ids = set ()
4959+ repr (scalars_df_default_index )
4960+ assert scalars_df_default_index .query_job is not None
4961+ job_ids .add (scalars_df_default_index .query_job .job_id )
4962+ scalars_df_default_index .to_pandas (allow_large_results = True )
4963+ job_ids .add (scalars_df_default_index .query_job .job_id )
49604964
4961- assert len (job_ids ) == 2
4965+ assert len (job_ids ) == 2
49624966
49634967
49644968def test_df_cached (scalars_df_index ):
@@ -5196,7 +5200,12 @@ def test_to_pandas_downsampling_option_override(session):
51965200 df = session .read_gbq ("bigframes-dev.bigframes_tests_sys.batting" )
51975201 download_size = 1
51985202
5199- df = df .to_pandas (max_download_size = download_size , sampling_method = "head" )
5203+ # limits only apply for allow_large_result=True
5204+ df = df .to_pandas (
5205+ max_download_size = download_size ,
5206+ sampling_method = "head" ,
5207+ allow_large_results = True ,
5208+ )
52005209
52015210 total_memory_bytes = df .memory_usage (deep = True ).sum ()
52025211 total_memory_mb = total_memory_bytes / (1024 * 1024 )
0 commit comments