Skip to content

Commit 89e3a7d

Browse files
committed
Adds logic to detect non-Sequence schema.fields value
1 parent e5ed4b8 commit 89e3a7d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

google/cloud/bigquery/table.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
import functools
2222
import operator
2323
import typing
24-
from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Union
24+
from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Union, Sequence
25+
2526
import warnings
2627

2728
try:
@@ -482,14 +483,16 @@ def schema(self, value):
482483
api_field,
483484
None,
484485
)
485-
else:
486+
elif isinstance(value, Sequence):
486487
value = _to_schema_fields(value)
487488
value = _build_schema_resource(value)
488489
_helpers._set_sub_prop(
489490
self._properties,
490491
api_field,
491492
value,
492493
)
494+
else:
495+
raise TypeError("Schema must be a Sequence (e.g. a list) or None.")
493496

494497
@property
495498
def labels(self):

0 commit comments

Comments
 (0)