Skip to content

Commit 96a9ded

Browse files
committed
populate created, started, ended
1 parent aecd84c commit 96a9ded

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

google/cloud/bigquery/_job_helpers.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,12 +596,9 @@ def do_query():
596596
total_bytes_processed=query_results.total_bytes_processed,
597597
slot_millis=query_results.slot_millis,
598598
destination=None,
599-
# TODO(tswast): After
600-
# https://github.com/googleapis/python-bigquery/pull/2260 goes in, add
601-
# created, started, ended properties here.
602-
created=None,
603-
started=None,
604-
ended=None,
599+
created=query_results.created,
600+
started=query_results.started,
601+
ended=query_results.ended,
605602
)
606603
)
607604
return table.RowIterator(

tests/unit/test_client_bigframes.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ def test_query_and_wait_bigframes_dry_run_no_callback(client):
7777

7878

7979
def test_query_and_wait_bigframes_callback(client):
80+
created = datetime.datetime(
81+
2025, 8, 18, 10, 11, 12, 345000, tzinfo=datetime.timezone.utc
82+
)
83+
started = datetime.datetime(
84+
2025, 8, 18, 10, 11, 13, 456000, tzinfo=datetime.timezone.utc
85+
)
86+
ended = datetime.datetime(
87+
2025, 8, 18, 10, 11, 14, 567000, tzinfo=datetime.timezone.utc
88+
)
8089
client._http.request.side_effect = [
8190
make_response(
8291
{
@@ -87,9 +96,9 @@ def test_query_and_wait_bigframes_callback(client):
8796
"totalBytesProcessed": "123",
8897
"totalSlotMs": "987",
8998
"jobComplete": True,
90-
# TODO(tswast): After
91-
# https://github.com/googleapis/python-bigquery/pull/2260 goes in, add
92-
# created, started, ended properties here.
99+
"creationTime": _to_millis(created),
100+
"startTime": _to_millis(started),
101+
"endTime": _to_millis(ended),
93102
}
94103
),
95104
]
@@ -115,9 +124,9 @@ def test_query_and_wait_bigframes_callback(client):
115124
total_rows=100,
116125
total_bytes_processed=123,
117126
slot_millis=987,
118-
created=None,
119-
started=None,
120-
ended=None,
127+
created=created,
128+
started=started,
129+
ended=ended,
121130
# No job ID or destination, because a basic query is eligible for jobs.query.
122131
job_id=None,
123132
destination=None,
@@ -330,6 +339,15 @@ def test_query_and_wait_bigframes_with_jobs_insert_dry_run_no_callback(client):
330339

331340

332341
def test_query_and_wait_bigframes_with_query_retry_callbacks(client):
342+
created = datetime.datetime(
343+
2025, 8, 18, 10, 11, 12, 345000, tzinfo=datetime.timezone.utc
344+
)
345+
started = datetime.datetime(
346+
2025, 8, 18, 10, 11, 13, 456000, tzinfo=datetime.timezone.utc
347+
)
348+
ended = datetime.datetime(
349+
2025, 8, 18, 10, 11, 14, 567000, tzinfo=datetime.timezone.utc
350+
)
333351
client._http.request.side_effect = [
334352
exceptions.InternalServerError(
335353
"first try", errors=({"reason": "jobInternalError"},)
@@ -343,9 +361,9 @@ def test_query_and_wait_bigframes_with_query_retry_callbacks(client):
343361
"totalBytesProcessed": "123",
344362
"totalSlotMs": "987",
345363
"jobComplete": True,
346-
# TODO(tswast): After
347-
# https://github.com/googleapis/python-bigquery/pull/2260 goes in, add
348-
# created, started, ended properties here.
364+
"creationTime": _to_millis(created),
365+
"startTime": _to_millis(started),
366+
"endTime": _to_millis(ended),
349367
}
350368
),
351369
]
@@ -381,9 +399,9 @@ def test_query_and_wait_bigframes_with_query_retry_callbacks(client):
381399
total_rows=100,
382400
total_bytes_processed=123,
383401
slot_millis=987,
384-
created=None,
385-
started=None,
386-
ended=None,
402+
created=created,
403+
started=started,
404+
ended=ended,
387405
# No job ID or destination, because a basic query is eligible for jobs.query.
388406
job_id=None,
389407
destination=None,

0 commit comments

Comments
 (0)