diff --git a/google/cloud/bigquery/table.py b/google/cloud/bigquery/table.py index 5a4de6a015..621ef2fa89 100644 --- a/google/cloud/bigquery/table.py +++ b/google/cloud/bigquery/table.py @@ -1019,6 +1019,9 @@ def _build_resource(self, filter_fields): def __repr__(self): return "Table({})".format(repr(self.reference)) + def __str__(self): + return f"{self.project}.{self.dataset_id}.{self.table_id}" + class TableListItem(_TableBase): """A read-only table resource from a list operation. diff --git a/tests/unit/test_table.py b/tests/unit/test_table.py index 66bc1d3db7..ba35b22974 100644 --- a/tests/unit/test_table.py +++ b/tests/unit/test_table.py @@ -27,6 +27,8 @@ import google.api_core.exceptions +from google.cloud.bigquery.table import TableReference + from google.cloud import bigquery_storage from google.cloud.bigquery_storage_v1.services.big_query_read.transports import ( grpc as big_query_read_grpc_transport, @@ -1410,6 +1412,11 @@ def test___repr__(self): ) self.assertEqual(repr(table1), expected) + def test___str__(self): + dataset = DatasetReference("project1", "dataset1") + table1 = self._make_one(TableReference(dataset, "table1")) + self.assertEqual(str(table1), "project1.dataset1.table1") + class Test_row_from_mapping(unittest.TestCase, _SchemaBase):