@@ -279,6 +279,38 @@ def to_api_repr(self):
279279 "tableId" : self ._table_id ,
280280 }
281281
282+ def to_bqstorage (self ):
283+ """Construct a BigQuery Storage API representation of this table.
284+
285+ If the ``table_id`` contains a partition identifier (e.g.
286+ ``my_table$201812``) or a snapshot identifier (e.g.
287+ ``mytable@1234567890``), it is ignored. Use
288+ :class:`google.cloud.bigquery_storage_v1beta1.types.TableReadOptions`
289+ to filter rows by partition. Use
290+ :class:`google.cloud.bigquery_storage_v1beta1.types.TableModifiers`
291+ to select a specific snapshot to read from.
292+
293+ Returns:
294+ google.cloud.bigquery_storage_v1beta1.types.TableReference:
295+ A reference to this table in the BigQuery Storage API.
296+ """
297+ from google .cloud import bigquery_storage_v1beta1
298+
299+ table_ref = bigquery_storage_v1beta1 .types .TableReference ()
300+ table_ref .project_id = self ._project
301+ table_ref .dataset_id = self ._dataset_id
302+ table_id = self ._table_id
303+
304+ if "@" in table_id :
305+ table_id = table_id .split ("@" )[0 ]
306+
307+ if "$" in table_id :
308+ table_id = table_id .split ("$" )[0 ]
309+
310+ table_ref .table_id = table_id
311+
312+ return table_ref
313+
282314 def _key (self ):
283315 """A tuple key that uniquely describes this field.
284316
@@ -820,6 +852,15 @@ def to_api_repr(self):
820852 """
821853 return copy .deepcopy (self ._properties )
822854
855+ def to_bqstorage (self ):
856+ """Construct a BigQuery Storage API representation of this table.
857+
858+ Returns:
859+ google.cloud.bigquery_storage_v1beta1.types.TableReference:
860+ A reference to this table in the BigQuery Storage API.
861+ """
862+ return self .reference .to_bqstorage ()
863+
823864 def _build_resource (self , filter_fields ):
824865 """Generate a resource for ``update``."""
825866 partial = {}
@@ -971,6 +1012,41 @@ def friendly_name(self):
9711012
9721013 view_use_legacy_sql = property (_view_use_legacy_sql_getter )
9731014
1015+ @classmethod
1016+ def from_string (cls , full_table_id ):
1017+ """Construct a table from fully-qualified table ID.
1018+
1019+ Args:
1020+ full_table_id (str):
1021+ A fully-qualified table ID in standard SQL format. Must
1022+ included a project ID, dataset ID, and table ID, each
1023+ separated by ``.``.
1024+
1025+ Returns:
1026+ Table: Table parsed from ``full_table_id``.
1027+
1028+ Examples:
1029+ >>> Table.from_string('my-project.mydataset.mytable')
1030+ Table(TableRef...(D...('my-project', 'mydataset'), 'mytable'))
1031+
1032+ Raises:
1033+ ValueError:
1034+ If ``full_table_id`` is not a fully-qualified table ID in
1035+ standard SQL format.
1036+ """
1037+ return cls (
1038+ {"tableReference" : TableReference .from_string (full_table_id ).to_api_repr ()}
1039+ )
1040+
1041+ def to_bqstorage (self ):
1042+ """Construct a BigQuery Storage API representation of this table.
1043+
1044+ Returns:
1045+ google.cloud.bigquery_storage_v1beta1.types.TableReference:
1046+ A reference to this table in the BigQuery Storage API.
1047+ """
1048+ return self .reference .to_bqstorage ()
1049+
9741050
9751051def _row_from_mapping (mapping , schema ):
9761052 """Convert a mapping to a row tuple using the schema.
0 commit comments