Skip to content

Commit 827b81c

Browse files
committed
add QueryReceivedEvent
1 parent 4ab9b83 commit 827b81c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

google/cloud/bigquery/_job_helpers.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from google.api_core import retry as retries
5050

5151
from google.cloud.bigquery import job
52+
import google.cloud.bigquery.job.query
5253
import google.cloud.bigquery.query
5354
from google.cloud.bigquery import table
5455
import google.cloud.bigquery.retry
@@ -667,6 +668,16 @@ def _wait_or_cancel(
667668
the job.
668669
"""
669670
try:
671+
callback(
672+
QueryReceivedEvent(
673+
billing_project=job.project,
674+
location=job.location,
675+
job_id=job.job_id,
676+
statement_type=job.statement_type,
677+
state=job.state,
678+
query_plan=job.query_plan,
679+
)
680+
)
670681
query_results = job.result(
671682
page_size=page_size,
672683
max_results=max_results,
@@ -710,6 +721,18 @@ class QueryFinishedEvent:
710721
slot_millis: Optional[int]
711722

712723

724+
@dataclasses.dataclass(frozen=True)
725+
class QueryReceivedEvent:
726+
"""Query received and acknowledged by the BigQuery API."""
727+
728+
billing_project: str
729+
location: Optional[str]
730+
job_id: Optional[str]
731+
statement_type: Optional[str]
732+
state: Optional[str]
733+
query_plan: Optional[list[google.cloud.bigquery.job.query.QueryPlanEntry]]
734+
735+
713736
@dataclasses.dataclass(frozen=True)
714737
class QuerySentEvent:
715738
"""Query sent to BigQuery."""

0 commit comments

Comments
 (0)