|
18 | 18 | import enum |
19 | 19 | from typing import Any, Dict, Iterable, Optional, Union |
20 | 20 |
|
| 21 | +from google.cloud.bigquery import _helpers |
21 | 22 | from google.cloud.bigquery import standard_sql |
22 | 23 | from google.cloud.bigquery.enums import StandardSqlTypeNames |
23 | 24 |
|
@@ -206,13 +207,6 @@ def __init__( |
206 | 207 | if fields: # Don't set the property if it's not set. |
207 | 208 | self._properties["fields"] = [field.to_api_repr() for field in fields] |
208 | 209 |
|
209 | | - @staticmethod |
210 | | - def __get_int(api_repr, name): |
211 | | - v = api_repr.get(name, _DEFAULT_VALUE) |
212 | | - if v is not _DEFAULT_VALUE: |
213 | | - v = int(v) |
214 | | - return v |
215 | | - |
216 | 210 | @classmethod |
217 | 211 | def from_api_repr(cls, api_repr: dict) -> "SchemaField": |
218 | 212 | """Return a ``SchemaField`` object deserialized from a dictionary. |
@@ -278,17 +272,17 @@ def description(self): |
278 | 272 | @property |
279 | 273 | def precision(self): |
280 | 274 | """Optional[int]: Precision (number of digits) for the NUMERIC field.""" |
281 | | - return self._properties.get("precision") |
| 275 | + return _helpers._int_or_none(self._properties.get("precision")) |
282 | 276 |
|
283 | 277 | @property |
284 | 278 | def scale(self): |
285 | 279 | """Optional[int]: Scale (digits after decimal) for the NUMERIC field.""" |
286 | | - return self._properties.get("scale") |
| 280 | + return _helpers._int_or_none(self._properties.get("scale")) |
287 | 281 |
|
288 | 282 | @property |
289 | 283 | def max_length(self): |
290 | 284 | """Optional[int]: Maximum length for the STRING or BYTES field.""" |
291 | | - return self._properties.get("maxLength") |
| 285 | + return _helpers._int_or_none(self._properties.get("maxLength")) |
292 | 286 |
|
293 | 287 | @property |
294 | 288 | def range_element_type(self): |
|
0 commit comments