Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support slot_ms in QueryPlanEntry #1831

Merged
merged 2 commits into from
Feb 27, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions google/cloud/bigquery/job/query.py
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
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