@@ -199,9 +199,10 @@ def __init__(
199199 self ._clients_provider = clients_provider
200200 self ._location = context .location or "US"
201201 else :
202- credentials , project = (
203- bigframes ._config .auth .resolve_credentials_and_project (context )
204- )
202+ (
203+ credentials ,
204+ project ,
205+ ) = bigframes ._config .auth .resolve_credentials_and_project (context )
205206 if context .location is None :
206207 with bigquery .Client (
207208 project = project ,
@@ -584,6 +585,7 @@ def _read_gbq_colab(
584585 self ,
585586 query : str ,
586587 * ,
588+ callback : Optional [Callable [[bigframes .core .events .Event ], None ]] = ...,
587589 pyformat_args : Optional [Dict [str , Any ]] = None ,
588590 dry_run : Literal [False ] = ...,
589591 ) -> dataframe .DataFrame : ...
@@ -593,6 +595,7 @@ def _read_gbq_colab(
593595 self ,
594596 query : str ,
595597 * ,
598+ callback : Optional [Callable [[bigframes .core .events .Event ], None ]] = ...,
596599 pyformat_args : Optional [Dict [str , Any ]] = None ,
597600 dry_run : Literal [True ] = ...,
598601 ) -> pandas .Series : ...
@@ -601,8 +604,8 @@ def _read_gbq_colab(
601604 def _read_gbq_colab (
602605 self ,
603606 query : str ,
604- # TODO: Add a callback parameter that takes some kind of Event object.
605607 * ,
608+ callback : Optional [Callable [[bigframes .core .events .Event ], None ]] = None ,
606609 pyformat_args : Optional [Dict [str , Any ]] = None ,
607610 dry_run : bool = False ,
608611 ) -> Union [dataframe .DataFrame , pandas .Series ]:
@@ -615,6 +618,8 @@ def _read_gbq_colab(
615618 query (str):
616619 A SQL query string to execute. Results (if any) are turned into
617620 a DataFrame.
621+ callback (Optional[Callable[[bigframes.core.events.Event], None]]):
622+ Callback to receive query execution events.
618623 pyformat_args (dict):
619624 A dictionary of potential variables to replace in ``query``.
620625 Note: strings are _not_ escaped. Use query parameters for these,
@@ -634,13 +639,21 @@ def _read_gbq_colab(
634639 dry_run = dry_run ,
635640 )
636641
637- return self ._loader .read_gbq_query (
638- query = query ,
639- index_col = bigframes .enums .DefaultIndexKind .NULL ,
640- force_total_order = False ,
641- dry_run = typing .cast (Union [Literal [False ], Literal [True ]], dry_run ),
642- allow_large_results = allow_large_results ,
643- )
642+ def _run_query ():
643+ return self ._loader .read_gbq_query (
644+ query = query ,
645+ index_col = bigframes .enums .DefaultIndexKind .NULL ,
646+ force_total_order = False ,
647+ dry_run = typing .cast (
648+ Union [Literal [False ], Literal [True ]], dry_run
649+ ),
650+ allow_large_results = allow_large_results ,
651+ )
652+
653+ if callback is not None :
654+ with self ._publisher .subscribe (callback ):
655+ return _run_query ()
656+ return _run_query ()
644657
645658 @overload
646659 def read_gbq_query ( # type: ignore[overload-overlap]
0 commit comments