@@ -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 ):
@@ -354,15 +367,6 @@ def from_api_repr(cls, resource):
354
367
ref ._properties = resource
355
368
return ref
356
369
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
-
366
370
def __eq__ (self , other ):
367
371
if not isinstance (other , RoutineArgument ):
368
372
return NotImplemented
@@ -374,7 +378,7 @@ def __ne__(self, other):
374
378
def __repr__ (self ):
375
379
all_properties = [
376
380
"{}={}" .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 )
378
382
]
379
383
return "RoutineArgument({})" .format (", " .join (all_properties ))
380
384
@@ -458,15 +462,6 @@ def from_string(cls, routine_id, default_project=None):
458
462
{"projectId" : proj , "datasetId" : dset , "routineId" : routine }
459
463
)
460
464
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
-
470
465
def __eq__ (self , other ):
471
466
"""Two RoutineReferences are equal if they point to the same routine."""
472
467
if not isinstance (other , RoutineReference ):
0 commit comments