Skip to content

Commit edcb79c

Browse files
bmwantLinchin
andauthored
fix: do not set job timeout extra property if None (#1987)
Co-authored-by: Lingqing Gan <[email protected]>
1 parent fabb2ba commit edcb79c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

google/cloud/bigquery/job/base.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,11 @@ def job_timeout_ms(self, value):
218218
err.__traceback__
219219
)
220220

221-
""" Docs indicate a string is expected by the API """
222-
self._properties["jobTimeoutMs"] = str(value)
221+
if value is not None:
222+
# docs indicate a string is expected by the API
223+
self._properties["jobTimeoutMs"] = str(value)
224+
else:
225+
self._properties.pop("jobTimeoutMs", None)
223226

224227
@property
225228
def labels(self):

tests/unit/job/test_base.py

+18
Original file line numberDiff line numberDiff line change
@@ -1320,3 +1320,21 @@ def test_job_timeout_ms(self):
13201320
# Confirm that integers get converted to strings.
13211321
job_config.job_timeout_ms = 5000
13221322
assert job_config.job_timeout_ms == "5000" # int is converted to string
1323+
1324+
def test_job_timeout_is_none_when_set_none(self):
1325+
job_config = self._make_one()
1326+
job_config.job_timeout_ms = None
1327+
# Confirm value is None and not literal string 'None'
1328+
assert job_config.job_timeout_ms is None
1329+
1330+
def test_job_timeout_properties(self):
1331+
# Make sure any value stored in properties is erased
1332+
# when setting job_timeout to None.
1333+
job_config = self._make_one()
1334+
job_config.job_timeout_ms = 4200
1335+
assert job_config.job_timeout_ms == "4200"
1336+
assert job_config._properties.get("jobTimeoutMs") == "4200"
1337+
1338+
job_config.job_timeout_ms = None
1339+
assert job_config.job_timeout_ms is None
1340+
assert "jobTimeoutMs" not in job_config._properties

0 commit comments

Comments
 (0)