@@ -328,33 +328,35 @@ def _read_gbq_colab(
328328 if pyformat_args is None :
329329 pyformat_args = {}
330330
331- # Only try to set the global location if it's not a dry run. We don't want
332- # to bind to a location too early. This is especially important if the query
333- # only refers to local data and not any BigQuery tables.
334- if dry_run :
335- result = _try_read_gbq_colab_sessionless_dry_run (
336- query_or_table , pyformat_args = pyformat_args
337- )
331+ with warnings .catch_warnings ():
332+ warnings .simplefilter ("ignore" , category = FutureWarning )
333+
334+ # Only try to set the global location if it's not a dry run. We don't want
335+ # to bind to a location too early. This is especially important if the query
336+ # only refers to local data and not any BigQuery tables.
337+ if dry_run :
338+ result = _try_read_gbq_colab_sessionless_dry_run (
339+ query_or_table , pyformat_args = pyformat_args
340+ )
338341
339- if result is not None :
340- return result
341-
342- # If we made it this far, we must have a session that has already
343- # started. That means we can safely call the "real" _read_gbq_colab,
344- # which generates slightly nicer SQL.
345- else :
346- # Delay formatting the query with the special "session-less" logic. This
347- # avoids doing unnecessary work if the session already has a location or has
348- # already started.
349- create_query = functools .partial (
350- bigframes .core .pyformat .pyformat ,
351- query_or_table ,
352- pyformat_args = pyformat_args ,
353- dry_run = True ,
354- )
355- _set_default_session_location_if_possible_deferred_query (create_query )
356- if not config .options .bigquery ._session_started :
357- with warnings .catch_warnings ():
342+ if result is not None :
343+ return result
344+
345+ # If we made it this far, we must have a session that has already
346+ # started. That means we can safely call the "real" _read_gbq_colab,
347+ # which generates slightly nicer SQL.
348+ else :
349+ # Delay formatting the query with the special "session-less" logic. This
350+ # avoids doing unnecessary work if the session already has a location or has
351+ # already started.
352+ create_query = functools .partial (
353+ bigframes .core .pyformat .pyformat ,
354+ query_or_table ,
355+ pyformat_args = pyformat_args ,
356+ dry_run = True ,
357+ )
358+ _set_default_session_location_if_possible_deferred_query (create_query )
359+ if not config .options .bigquery ._session_started :
358360 # Don't warning about Polars in SQL cell.
359361 # Related to b/437090788.
360362 try :
@@ -364,12 +366,12 @@ def _read_gbq_colab(
364366 except ImportError :
365367 pass # don't fail if polars isn't available
366368
367- return global_session .with_default_session (
368- bigframes .session .Session ._read_gbq_colab ,
369- query_or_table ,
370- pyformat_args = pyformat_args ,
371- dry_run = dry_run ,
372- )
369+ return global_session .with_default_session (
370+ bigframes .session .Session ._read_gbq_colab ,
371+ query_or_table ,
372+ pyformat_args = pyformat_args ,
373+ dry_run = dry_run ,
374+ )
373375
374376
375377def read_gbq_model (model_name : str ):
0 commit comments