Skip to content

Commit d62cabb

Browse files
authored
feat: support slot_ms in QueryPlanEntry (#1831)
1 parent a208b6a commit d62cabb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

google/cloud/bigquery/job/query.py

+5
Original file line numberDiff line numberDiff line change
@@ -2263,6 +2263,11 @@ def steps(self):
22632263
for step in self._properties.get("steps", [])
22642264
]
22652265

2266+
@property
2267+
def slot_ms(self):
2268+
"""Optional[int]: Slot-milliseconds used by the stage."""
2269+
return _helpers._int_or_none(self._properties.get("slotMs"))
2270+
22662271

22672272
class TimelineEntry(object):
22682273
"""TimelineEntry represents progress of a query job at a particular

tests/unit/job/test_query_stats.py

+4
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ class TestQueryPlanEntry(_Base):
261261
STATUS = "STATUS"
262262
SHUFFLE_OUTPUT_BYTES = 1024
263263
SHUFFLE_OUTPUT_BYTES_SPILLED = 1
264+
SLOT_MS = 25
264265

265266
START_RFC3339_MICROS = "2018-04-01T00:00:00.000000Z"
266267
END_RFC3339_MICROS = "2018-04-01T00:00:04.000000Z"
@@ -305,6 +306,7 @@ def test_from_api_repr_empty(self):
305306
self.assertIsNone(entry.shuffle_output_bytes)
306307
self.assertIsNone(entry.shuffle_output_bytes_spilled)
307308
self.assertEqual(entry.steps, [])
309+
self.assertIsNone(entry.slot_ms)
308310

309311
def test_from_api_repr_normal(self):
310312
from google.cloud.bigquery.job import QueryPlanEntryStep
@@ -348,6 +350,7 @@ def test_from_api_repr_normal(self):
348350
"substeps": TestQueryPlanEntryStep.SUBSTEPS,
349351
}
350352
],
353+
"slotMs": self.SLOT_MS,
351354
}
352355
klass = self._get_target_class()
353356

@@ -366,6 +369,7 @@ def test_from_api_repr_normal(self):
366369
self.assertEqual(entry.records_written, self.RECORDS_WRITTEN)
367370
self.assertEqual(entry.status, self.STATUS)
368371
self.assertEqual(entry.steps, steps)
372+
self.assertEqual(entry.slot_ms, self.SLOT_MS)
369373

370374
def test_start(self):
371375
from google.cloud._helpers import _RFC3339_MICROS

0 commit comments

Comments
 (0)