@@ -189,15 +189,19 @@ def return_type(self):
189
189
https://cloud.google.com/bigquery/docs/reference/rest/v2/routines#resource-routine
190
190
"""
191
191
resource = self ._properties .get (self ._PROPERTY_TO_API_FIELD ["return_type" ])
192
+ if not resource :
193
+ return resource
192
194
output = google .cloud .bigquery_v2 .types .StandardSqlDataType ()
193
195
output = json_format .ParseDict (resource , output , ignore_unknown_fields = True )
194
196
return output
195
197
196
198
@return_type .setter
197
199
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
201
205
202
206
@property
203
207
def imported_libraries (self ):
@@ -257,6 +261,11 @@ def _build_resource(self, filter_fields):
257
261
"""Generate a resource for ``update``."""
258
262
return _helpers ._build_resource_from_properties (self , filter_fields )
259
263
264
+ def __repr__ (self ):
265
+ return "Routine('{}.{}.{}')" .format (
266
+ self .project , self .dataset_id , self .routine_id
267
+ )
268
+
260
269
261
270
class RoutineArgument (object ):
262
271
"""Input/output argument of a function or a stored procedure.
@@ -328,15 +337,19 @@ def data_type(self):
328
337
https://cloud.google.com/bigquery/docs/reference/rest/v2/StandardSqlDataType
329
338
"""
330
339
resource = self ._properties .get (self ._PROPERTY_TO_API_FIELD ["data_type" ])
340
+ if not resource :
341
+ return resource
331
342
output = google .cloud .bigquery_v2 .types .StandardSqlDataType ()
332
343
output = json_format .ParseDict (resource , output , ignore_unknown_fields = True )
333
344
return output
334
345
335
346
@data_type .setter
336
347
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
340
353
341
354
@classmethod
342
355
def from_api_repr (cls , resource ):
@@ -374,7 +387,7 @@ def __ne__(self, other):
374
387
def __repr__ (self ):
375
388
all_properties = [
376
389
"{}={}" .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 )
378
391
]
379
392
return "RoutineArgument({})" .format (", " .join (all_properties ))
380
393
0 commit comments