@@ -189,15 +189,19 @@ def return_type(self):
189189 https://cloud.google.com/bigquery/docs/reference/rest/v2/routines#resource-routine
190190 """
191191 resource = self ._properties .get (self ._PROPERTY_TO_API_FIELD ["return_type" ])
192+ if not resource :
193+ return resource
192194 output = google .cloud .bigquery_v2 .types .StandardSqlDataType ()
193195 output = json_format .ParseDict (resource , output , ignore_unknown_fields = True )
194196 return output
195197
196198 @return_type .setter
197199 def return_type (self , value ):
198- self ._properties [
199- self ._PROPERTY_TO_API_FIELD ["return_type" ]
200- ] = json_format .MessageToDict (value )
200+ if value :
201+ resource = json_format .MessageToDict (value )
202+ else :
203+ resource = None
204+ self ._properties [self ._PROPERTY_TO_API_FIELD ["return_type" ]] = resource
201205
202206 @property
203207 def imported_libraries (self ):
@@ -257,6 +261,11 @@ def _build_resource(self, filter_fields):
257261 """Generate a resource for ``update``."""
258262 return _helpers ._build_resource_from_properties (self , filter_fields )
259263
264+ def __repr__ (self ):
265+ return "Routine('{}.{}.{}')" .format (
266+ self .project , self .dataset_id , self .routine_id
267+ )
268+
260269
261270class RoutineArgument (object ):
262271 """Input/output argument of a function or a stored procedure.
@@ -328,15 +337,19 @@ def data_type(self):
328337 https://cloud.google.com/bigquery/docs/reference/rest/v2/StandardSqlDataType
329338 """
330339 resource = self ._properties .get (self ._PROPERTY_TO_API_FIELD ["data_type" ])
340+ if not resource :
341+ return resource
331342 output = google .cloud .bigquery_v2 .types .StandardSqlDataType ()
332343 output = json_format .ParseDict (resource , output , ignore_unknown_fields = True )
333344 return output
334345
335346 @data_type .setter
336347 def data_type (self , value ):
337- self ._properties [
338- self ._PROPERTY_TO_API_FIELD ["data_type" ]
339- ] = json_format .MessageToDict (value )
348+ if value :
349+ resource = json_format .MessageToDict (value )
350+ else :
351+ resource = None
352+ self ._properties [self ._PROPERTY_TO_API_FIELD ["data_type" ]] = resource
340353
341354 @classmethod
342355 def from_api_repr (cls , resource ):
@@ -354,15 +367,6 @@ def from_api_repr(cls, resource):
354367 ref ._properties = resource
355368 return ref
356369
357- def to_api_repr (self ):
358- """Construct the API resource representation of this routine argument.
359-
360- Returns:
361- Dict[str, object]:
362- Routine argument represented as an API resource.
363- """
364- return self ._properties
365-
366370 def __eq__ (self , other ):
367371 if not isinstance (other , RoutineArgument ):
368372 return NotImplemented
@@ -374,7 +378,7 @@ def __ne__(self, other):
374378 def __repr__ (self ):
375379 all_properties = [
376380 "{}={}" .format (property_name , repr (getattr (self , property_name )))
377- for property_name in self ._PROPERTY_TO_API_FIELD
381+ for property_name in sorted ( self ._PROPERTY_TO_API_FIELD )
378382 ]
379383 return "RoutineArgument({})" .format (", " .join (all_properties ))
380384
@@ -458,15 +462,6 @@ def from_string(cls, routine_id, default_project=None):
458462 {"projectId" : proj , "datasetId" : dset , "routineId" : routine }
459463 )
460464
461- def to_api_repr (self ):
462- """Construct the API resource representation of this routine reference.
463-
464- Returns:
465- Dict[str, object]:
466- Routine reference represented as an API resource.
467- """
468- return self ._properties
469-
470465 def __eq__ (self , other ):
471466 """Two RoutineReferences are equal if they point to the same routine."""
472467 if not isinstance (other , RoutineReference ):
0 commit comments