As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

google.cloud.bigquery.routine.Routine

class google.cloud.bigquery.routine.Routine(routine_ref, **kwargs)[source]

Resource representing a user-defined routine.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/routines

Parameters
  • routine_ref (Union[str, google.cloud.bigquery.routine.RoutineReference]) – A pointer to a routine. If routine_ref is a string, it must included a project ID, dataset ID, and routine ID, each separated by ..

  • **kwargs (Dict) – Initial property values.

__init__(routine_ref, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(routine_ref, **kwargs)

Initialize self.

from_api_repr(resource)

Factory: construct a routine given its API representation.

to_api_repr()

Construct the API resource representation of this routine.

Attributes

arguments

Input/output argument of a function or a stored procedure.

body

The body of the routine.

created

Datetime at which the routine was created (None until set from the server).

dataset_id

ID of dataset containing the routine.

description

Description of the routine (defaults to None).

determinism_level

(experimental) The determinism level of the JavaScript UDF if defined.

etag

ETag for the resource (None until set from the server).

imported_libraries

The path of the imported JavaScript libraries.

language

The language of the routine.

modified

Datetime at which the routine was last modified (None until set from the server).

path

URL path for the routine’s APIs.

project

ID of the project containing the routine.

reference

Reference describing the ID of this routine.

return_table_type

The return type of a Table Valued Function (TVF) routine.

return_type

Return type of the routine.

routine_id

The routine ID.

type_

The fine-grained type of the routine.

property arguments

Input/output argument of a function or a stored procedure.

In-place modification is not supported. To set, replace the entire property value with the modified list of RoutineArgument objects.

Type

List[google.cloud.bigquery.routine.RoutineArgument]

property body

The body of the routine.

Type

str

property created

Datetime at which the routine was created (None until set from the server).

Read-only.

Type

Optional[datetime.datetime]

property dataset_id

ID of dataset containing the routine.

Type

str

property description

Description of the routine (defaults to None).

Type

Optional[str]

property determinism_level

(experimental) The determinism level of the JavaScript UDF if defined.

Type

Optional[str]

property etag

ETag for the resource (None until set from the server).

Read-only.

Type

str

classmethod from_api_repr(resource: dict)google.cloud.bigquery.routine.routine.Routine[source]

Factory: construct a routine given its API representation.

Parameters

resource (Dict[str, object]) – Resource, as returned from the API.

Returns

Python object, as parsed from resource.

Return type

google.cloud.bigquery.routine.Routine

property imported_libraries

The path of the imported JavaScript libraries.

The language must equal JAVACRIPT.

Examples

Set the imported_libraries to a list of Google Cloud Storage URIs.

routine = bigquery.Routine("proj.dataset.routine_id")
routine.imported_libraries = [
    "gs://cloud-samples-data/bigquery/udfs/max-value.js",
]
Type

List[str]

property language

The language of the routine.

Defaults to SQL.

Type

Optional[str]

property modified

Datetime at which the routine was last modified (None until set from the server).

Read-only.

Type

Optional[datetime.datetime]

property path

URL path for the routine’s APIs.

Type

str

property project

ID of the project containing the routine.

Type

str

property reference

Reference describing the ID of this routine.

Type

google.cloud.bigquery.routine.RoutineReference

property return_table_type: google.cloud.bigquery_v2.types.standard_sql.StandardSqlTableType

The return type of a Table Valued Function (TVF) routine.

New in version 2.22.0.

property return_type

Return type of the routine.

If absent, the return type is inferred from body at query time in each query that references this routine. If present, then the evaluated result will be cast to the specified returned type at query time.

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/routines#Routine.FIELDS.return_type

Type

google.cloud.bigquery_v2.types.StandardSqlDataType

property routine_id

The routine ID.

Type

str

to_api_repr()dict[source]

Construct the API resource representation of this routine.

Returns

Routine represented as an API resource.

Return type

Dict[str, object]

property type_

The fine-grained type of the routine.

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/routines#RoutineType

Type

str