def _bq_cast(string_field, bq_type):
 if (string_field is None):
  return None
 elif ((bq_type == 'INTEGER') or (bq_type == 'TIMESTAMP')):
  return int(string_field)
 elif (bq_type == 'FLOAT'):
  return float(string_field)
 elif (bq_type == 'BOOLEAN'):
  assert (string_field in set(['true', 'false']))
  return (string_field == 'true')
 else:
  return string_field

def _bq_cast ( string_field , bq_type ) : if ( string_field is None ) : return None elif ( ( bq_type == 'INTEGER' ) or ( bq_type == 'TIMESTAMP' ) ) : return int ( string_field ) elif ( bq_type == 'FLOAT' ) : return float ( string_field ) elif ( bq_type == 'BOOLEAN' ) : assert ( string_field in set ( [ 'true' , 'false' ] ) ) return ( string_field == 'true' ) else : return string_field
helper method that casts a bigquery row to the appropriate data types .