Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions google/cloud/bigquery/job/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,11 @@ def steps(self):
for step in self._properties.get("steps", [])
]

@property
def slot_ms(self):
"""Optional[int]: Slot-milliseconds used by the stage."""
return _helpers._int_or_none(self._properties.get("slotMs"))


class TimelineEntry(object):
"""TimelineEntry represents progress of a query job at a particular
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/job/test_query_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ class TestQueryPlanEntry(_Base):
STATUS = "STATUS"
SHUFFLE_OUTPUT_BYTES = 1024
SHUFFLE_OUTPUT_BYTES_SPILLED = 1
SLOT_MS = 25

START_RFC3339_MICROS = "2018-04-01T00:00:00.000000Z"
END_RFC3339_MICROS = "2018-04-01T00:00:04.000000Z"
Expand Down Expand Up @@ -305,6 +306,7 @@ def test_from_api_repr_empty(self):
self.assertIsNone(entry.shuffle_output_bytes)
self.assertIsNone(entry.shuffle_output_bytes_spilled)
self.assertEqual(entry.steps, [])
self.assertIsNone(entry.slot_ms)

def test_from_api_repr_normal(self):
from google.cloud.bigquery.job import QueryPlanEntryStep
Expand Down Expand Up @@ -348,6 +350,7 @@ def test_from_api_repr_normal(self):
"substeps": TestQueryPlanEntryStep.SUBSTEPS,
}
],
"slotMs": self.SLOT_MS,
}
klass = self._get_target_class()

Expand All @@ -366,6 +369,7 @@ def test_from_api_repr_normal(self):
self.assertEqual(entry.records_written, self.RECORDS_WRITTEN)
self.assertEqual(entry.status, self.STATUS)
self.assertEqual(entry.steps, steps)
self.assertEqual(entry.slot_ms, self.SLOT_MS)

def test_start(self):
from google.cloud._helpers import _RFC3339_MICROS
Expand Down