@@ -501,6 +501,7 @@ def _to_schema_fields(schema):
501501 sequence is not a :class:`~google.cloud.bigquery.schema.SchemaField`
502502 instance or a compatible mapping representation of the field.
503503 """
504+
504505 for field in schema :
505506 if not isinstance (field , (SchemaField , collections .abc .Mapping )):
506507 raise ValueError (
@@ -598,59 +599,59 @@ def to_api_repr(self) -> dict:
598599 return answer
599600
600601
601- class TableSchema :
602- """Schema of a table
602+ # class TableSchema:
603+ # """Schema of a table
603604
604- Args:
605- fields (Optional[list]): Describes the fields in a table.
606- foreignTypeInfo (Optional[str]): Specifies metadata of the foreign data type
607- definition in field schema.
608- """
605+ # Args:
606+ # fields (Optional[list]): Describes the fields in a table.
607+ # foreignTypeInfo (Optional[str]): Specifies metadata of the foreign data type
608+ # definition in field schema.
609+ # """
609610
610- def __init__ (
611- self , fields : Optional [list ] = None , foreign_type_info : Optional [str ] = None
612- ):
613- self ._properties = {}
614- self .fields = fields
615- self .foreign_type_info = foreign_type_info
611+ # def __init__(
612+ # self, fields: Optional[list] = None, foreign_type_info: Optional[str] = None
613+ # ):
614+ # self._properties = {}
615+ # self.fields = fields
616+ # self.foreign_type_info = foreign_type_info
616617
617- @property
618- def fields (self ) -> Any :
619- """Describes the fields in a table."""
618+ # @property
619+ # def fields(self) -> Any:
620+ # """Describes the fields in a table."""
620621
621- return self ._properties .get ("fields" )
622+ # return self._properties.get("fields")
622623
623- @fields .setter
624- def fields (self , value : list , dtype : str ) -> str :
625- value = _isinstance_or_raise (value , list , none_allowed = True )
626- self ._properties ["fields" ] = value
624+ # @fields.setter
625+ # def fields(self, value: list, dtype: str) -> str:
626+ # value = _isinstance_or_raise(value, list, none_allowed=True)
627+ # self._properties["fields"] = value
627628
628- @property
629- def foreign_type_info (self ) -> Any :
630- """Optional. Specifies metadata of the foreign data type definition in
631- field schema (TableFieldSchema.foreign_type_definition)."""
629+ # @property
630+ # def foreign_type_info(self) -> Any:
631+ # """Optional. Specifies metadata of the foreign data type definition in
632+ # field schema (TableFieldSchema.foreign_type_definition)."""
632633
633- return self ._properties .get ("foreignTypeInfo" )
634+ # return self._properties.get("foreignTypeInfo")
634635
635- @foreign_type_info .setter
636- def foreign_type_info (self , value : str , dtype : str ) -> str :
637- if not isinstance (value , str ):
638- raise ValueError (
639- f"Pass { value } as a '{ repr (dtype )} '." f"Got { type (value )} ."
640- )
641- self ._properties ["foreignTypeInfo" ] = value
636+ # @foreign_type_info.setter
637+ # def foreign_type_info(self, value: str, dtype: str) -> str:
638+ # if not isinstance(value, str):
639+ # raise ValueError(
640+ # f"Pass {value} as a '{repr(dtype)}'." f"Got {type(value)}."
641+ # )
642+ # self._properties["foreignTypeInfo"] = value
642643
643- def to_api_repr (self ) -> dict :
644- """Build an API representation of this object.
644+ # def to_api_repr(self) -> dict:
645+ # """Build an API representation of this object.
645646
646- Returns:
647- Dict[str, Any]:
648- A dictionary in the format used by the BigQuery API.
649- """
650- return copy .deepcopy (self ._properties )
647+ # Returns:
648+ # Dict[str, Any]:
649+ # A dictionary in the format used by the BigQuery API.
650+ # """
651+ # return copy.deepcopy(self._properties)
651652
652- def from_api_repr (self , resource ):
653- return _from_api_repr (self , resource )
653+ # def from_api_repr(self, resource):
654+ # return _from_api_repr(self, resource)
654655
655656
656657class ForeignTypeInfo :
@@ -686,9 +687,22 @@ def to_api_repr(self) -> dict:
686687 A dictionary in the format used by the BigQuery API.
687688 """
688689 return copy .deepcopy (self ._properties )
690+
691+ @classmethod
692+ def from_api_repr (cls , resource ):
693+ """Factory: constructs an instance of the class (cls)
694+ given its API representation.
689695
690- def from_api_repr (self , resource ):
691- return _from_api_repr (self , resource )
696+ Args:
697+ resource (Dict[str, Any]):
698+ API representation of the object to be instantiated.
699+
700+ Returns:
701+ An instance of the class initialized with data from 'resource'.
702+ """
703+ config = cls ()
704+ config ._properties = copy .deepcopy (resource )
705+ return config
692706
693707
694708class StorageDescriptor :
0 commit comments