@@ -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 ):
@@ -374,7 +387,7 @@ def __ne__(self, other):
374387 def __repr__ (self ):
375388 all_properties = [
376389 "{}={}" .format (property_name , repr (getattr (self , property_name )))
377- for property_name in self ._PROPERTY_TO_API_FIELD
390+ for property_name in sorted ( self ._PROPERTY_TO_API_FIELD )
378391 ]
379392 return "RoutineArgument({})" .format (", " .join (all_properties ))
380393
0 commit comments