Skip to content

Commit 07c70f0

Browse files
feat: add method api_repr for table list item (#299)
1 parent 801e4c0 commit 07c70f0

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

google/cloud/bigquery/table.py

+8
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,14 @@ def to_bqstorage(self):
10711071
"""
10721072
return self.reference.to_bqstorage()
10731073

1074+
def to_api_repr(self):
1075+
"""Constructs the API resource of this table
1076+
1077+
Returns:
1078+
Dict[str, object]: Table represented as an API resource
1079+
"""
1080+
return copy.deepcopy(self._properties)
1081+
10741082

10751083
def _row_from_mapping(mapping, schema):
10761084
"""Convert a mapping to a row tuple using the schema.

tests/unit/test_table.py

+11
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,17 @@ def test_labels_update_in_place(self):
14331433
labels["foo"] = "bar" # update in place
14341434
self.assertEqual(table.labels, {"foo": "bar"})
14351435

1436+
def test_to_api_repr(self):
1437+
resource = {
1438+
"tableReference": {
1439+
"projectId": "testproject",
1440+
"datasetId": "testdataset",
1441+
"tableId": "testtable",
1442+
}
1443+
}
1444+
table = self._make_one(resource)
1445+
self.assertEqual(table.to_api_repr(), resource)
1446+
14361447

14371448
class TestRow(unittest.TestCase):
14381449
def test_row(self):

0 commit comments

Comments
 (0)