routines
Creates, updates, deletes, gets or lists a routines resource.
Overview
| Name | routines |
| Type | Resource |
| Id | google.bigquery.routines |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
arguments | array | Optional. |
buildStatus | object | Output only. The build status of the routine. This field is only applicable to Python UDFs. Preview (id: RoutineBuildStatus) |
creationTime | string (int64) | Output only. The time when this routine was created, in milliseconds since the epoch. |
dataGovernanceType | string | Optional. If set to DATA_MASKING, the function is validated and made available as a masking function. For more information, see Create custom masking routines. (DATA_GOVERNANCE_TYPE_UNSPECIFIED, DATA_MASKING) |
definitionBody | string | Required. The body of the routine. For functions, this is the expression in the AS clause. If language = "SQL", it is the substring inside (but excluding) the parentheses. For example, for the function created with the following statement: CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y)) The definition_body is concat(x, "\n", y) (\n is not replaced with linebreak). If language="JAVASCRIPT", it is the evaluated string in the AS clause. For example, for the function created with the following statement: CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n' The definition_body is return "\n";\n Note that both \n are replaced with linebreaks. If definition_body references another routine, then that routine must be fully qualified with its project ID. |
description | string | Optional. The description of the routine, if defined. |
determinismLevel | string | Optional. The determinism level of the JavaScript UDF, if defined. (DETERMINISM_LEVEL_UNSPECIFIED, DETERMINISTIC, NOT_DETERMINISTIC) |
etag | string | Output only. A hash of this resource. |
externalRuntimeOptions | object | Optional. Options for the runtime of the external system executing the routine. This field is only applicable for Python UDFs. Preview (id: ExternalRuntimeOptions) |
importedLibraries | array | Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries. |
language | string | Optional. Defaults to "SQL" if remote_function_options field is absent, not set otherwise. (LANGUAGE_UNSPECIFIED, SQL, JAVASCRIPT, PYTHON, JAVA, SCALA) |
lastModifiedTime | string (int64) | Output only. The time when this routine was last modified, in milliseconds since the epoch. |
pythonOptions | object | Optional. Options for the Python UDF. Preview (id: PythonOptions) |
remoteFunctionOptions | object | Optional. Remote function specific options. (id: RemoteFunctionOptions) |
returnTableType | object | Optional. Can be set only if routine_type = "TABLE_VALUED_FUNCTION". If absent, the return table type is inferred from definition_body at query time in each query that references this routine. If present, then the columns in the evaluated table result will be cast to match the column types specified in return table type, at query time. (id: StandardSqlTableType) |
returnType | object | Optional if language = "SQL"; required otherwise. Cannot be set if routine_type = "TABLE_VALUED_FUNCTION". If absent, the return type is inferred from definition_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. For example, for the functions created with the following statements: * CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y); * CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1)); * CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1)); The return_type is {type_kind: "FLOAT64"} for Add and Decrement, and is absent for Increment (inferred as FLOAT64 at query time). Suppose the function Add is replaced by CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y); Then the inferred return type of Increment is automatically changed to INT64 at query time, while the return type of Decrement remains FLOAT64. (id: StandardSqlDataType) |
routineReference | object | Required. Reference describing the ID of this routine. (id: RoutineReference) |
routineType | string | Required. The type of routine. (ROUTINE_TYPE_UNSPECIFIED, SCALAR_FUNCTION, PROCEDURE, TABLE_VALUED_FUNCTION, AGGREGATE_FUNCTION) |
securityMode | string | Optional. The security mode of the routine, if defined. If not defined, the security mode is automatically determined from the routine's configuration. (SECURITY_MODE_UNSPECIFIED, DEFINER, INVOKER) |
sparkOptions | object | Optional. Spark specific options. (id: SparkOptions) |
strictMode | boolean | Optional. Use this option to catch many common errors. Error checking is not exhaustive, and successfully creating a procedure doesn't guarantee that the procedure will successfully execute at runtime. If strictMode is set to TRUE, the procedure body is further checked for errors such as non-existent tables or columns. The CREATE PROCEDURE statement fails if the body fails any of these checks. If strictMode is set to FALSE, the procedure body is checked only for syntax. For procedures that invoke themselves recursively, specify strictMode=FALSE to avoid non-existent procedure errors during validation. Default value is TRUE. |
| Name | Datatype | Description |
|---|---|---|
arguments | array | Optional. |
buildStatus | object | Output only. The build status of the routine. This field is only applicable to Python UDFs. Preview (id: RoutineBuildStatus) |
creationTime | string (int64) | Output only. The time when this routine was created, in milliseconds since the epoch. |
dataGovernanceType | string | Optional. If set to DATA_MASKING, the function is validated and made available as a masking function. For more information, see Create custom masking routines. (DATA_GOVERNANCE_TYPE_UNSPECIFIED, DATA_MASKING) |
definitionBody | string | Required. The body of the routine. For functions, this is the expression in the AS clause. If language = "SQL", it is the substring inside (but excluding) the parentheses. For example, for the function created with the following statement: CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y)) The definition_body is concat(x, "\n", y) (\n is not replaced with linebreak). If language="JAVASCRIPT", it is the evaluated string in the AS clause. For example, for the function created with the following statement: CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n' The definition_body is return "\n";\n Note that both \n are replaced with linebreaks. If definition_body references another routine, then that routine must be fully qualified with its project ID. |
description | string | Optional. The description of the routine, if defined. |
determinismLevel | string | Optional. The determinism level of the JavaScript UDF, if defined. (DETERMINISM_LEVEL_UNSPECIFIED, DETERMINISTIC, NOT_DETERMINISTIC) |
etag | string | Output only. A hash of this resource. |
externalRuntimeOptions | object | Optional. Options for the runtime of the external system executing the routine. This field is only applicable for Python UDFs. Preview (id: ExternalRuntimeOptions) |
importedLibraries | array | Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries. |
language | string | Optional. Defaults to "SQL" if remote_function_options field is absent, not set otherwise. (LANGUAGE_UNSPECIFIED, SQL, JAVASCRIPT, PYTHON, JAVA, SCALA) |
lastModifiedTime | string (int64) | Output only. The time when this routine was last modified, in milliseconds since the epoch. |
pythonOptions | object | Optional. Options for the Python UDF. Preview (id: PythonOptions) |
remoteFunctionOptions | object | Optional. Remote function specific options. (id: RemoteFunctionOptions) |
returnTableType | object | Optional. Can be set only if routine_type = "TABLE_VALUED_FUNCTION". If absent, the return table type is inferred from definition_body at query time in each query that references this routine. If present, then the columns in the evaluated table result will be cast to match the column types specified in return table type, at query time. (id: StandardSqlTableType) |
returnType | object | Optional if language = "SQL"; required otherwise. Cannot be set if routine_type = "TABLE_VALUED_FUNCTION". If absent, the return type is inferred from definition_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. For example, for the functions created with the following statements: * CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y); * CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1)); * CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1)); The return_type is {type_kind: "FLOAT64"} for Add and Decrement, and is absent for Increment (inferred as FLOAT64 at query time). Suppose the function Add is replaced by CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y); Then the inferred return type of Increment is automatically changed to INT64 at query time, while the return type of Decrement remains FLOAT64. (id: StandardSqlDataType) |
routineReference | object | Required. Reference describing the ID of this routine. (id: RoutineReference) |
routineType | string | Required. The type of routine. (ROUTINE_TYPE_UNSPECIFIED, SCALAR_FUNCTION, PROCEDURE, TABLE_VALUED_FUNCTION, AGGREGATE_FUNCTION) |
securityMode | string | Optional. The security mode of the routine, if defined. If not defined, the security mode is automatically determined from the routine's configuration. (SECURITY_MODE_UNSPECIFIED, DEFINER, INVOKER) |
sparkOptions | object | Optional. Spark specific options. (id: SparkOptions) |
strictMode | boolean | Optional. Use this option to catch many common errors. Error checking is not exhaustive, and successfully creating a procedure doesn't guarantee that the procedure will successfully execute at runtime. If strictMode is set to TRUE, the procedure body is further checked for errors such as non-existent tables or columns. The CREATE PROCEDURE statement fails if the body fails any of these checks. If strictMode is set to FALSE, the procedure body is checked only for syntax. For procedures that invoke themselves recursively, specify strictMode=FALSE to avoid non-existent procedure errors during validation. Default value is TRUE. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | projectId, +datasetId, +routineId | readMask | Gets the specified routine resource by routine ID. # IAM Permissions Requires the bigquery.routines.get permission on the routine. |
list | select | projectId, +datasetId | maxResults, filter, pageToken, readMask | Lists all routines in the specified dataset. Requires the READER dataset role. # IAM Permissions Requires the bigquery.routines.list permission on the dataset. |
insert | insert | projectId, +datasetId | Creates a new routine in the dataset. # IAM Permissions Requires the bigquery.routines.create permission on the dataset. | |
update | replace | projectId, +datasetId, +routineId | Updates information in an existing routine. The update method replaces the entire Routine resource. # IAM Permissions Requires the bigquery.routines.update permission on the routine. | |
delete | delete | projectId, +datasetId, +routineId | Deletes the routine specified by routineId from the dataset. # IAM Permissions Requires the bigquery.routines.delete permission on the routine. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
+datasetId | string | |
+routineId | string | |
projectId | string | |
filter | string | |
maxResults | integer (uint32) | |
pageToken | string | |
readMask | string (google-fieldmask) |
SELECT examples
- get
- list
Gets the specified routine resource by routine ID. # IAM Permissions Requires the bigquery.routines.get permission on the routine.
SELECT
arguments,
buildStatus,
creationTime,
dataGovernanceType,
definitionBody,
description,
determinismLevel,
etag,
externalRuntimeOptions,
importedLibraries,
language,
lastModifiedTime,
pythonOptions,
remoteFunctionOptions,
returnTableType,
returnType,
routineReference,
routineType,
securityMode,
sparkOptions,
strictMode
FROM google.bigquery.routines
WHERE projectId = '{{ projectId }}' -- required
AND +datasetId = '{{ +datasetId }}' -- required
AND +routineId = '{{ +routineId }}' -- required
AND readMask = '{{ readMask }}'
;
Lists all routines in the specified dataset. Requires the READER dataset role. # IAM Permissions Requires the bigquery.routines.list permission on the dataset.
SELECT
arguments,
buildStatus,
creationTime,
dataGovernanceType,
definitionBody,
description,
determinismLevel,
etag,
externalRuntimeOptions,
importedLibraries,
language,
lastModifiedTime,
pythonOptions,
remoteFunctionOptions,
returnTableType,
returnType,
routineReference,
routineType,
securityMode,
sparkOptions,
strictMode
FROM google.bigquery.routines
WHERE projectId = '{{ projectId }}' -- required
AND +datasetId = '{{ +datasetId }}' -- required
AND maxResults = '{{ maxResults }}'
AND filter = '{{ filter }}'
AND pageToken = '{{ pageToken }}'
AND readMask = '{{ readMask }}'
;
INSERT examples
- insert
- Manifest
Creates a new routine in the dataset. # IAM Permissions Requires the bigquery.routines.create permission on the dataset.
INSERT INTO google.bigquery.routines (
data__strictMode,
data__sparkOptions,
data__returnType,
data__externalRuntimeOptions,
data__arguments,
data__returnTableType,
data__remoteFunctionOptions,
data__securityMode,
data__definitionBody,
data__routineReference,
data__importedLibraries,
data__dataGovernanceType,
data__language,
data__description,
data__determinismLevel,
data__pythonOptions,
data__routineType,
projectId,
+datasetId
)
SELECT
{{ strictMode }},
'{{ sparkOptions }}',
'{{ returnType }}',
'{{ externalRuntimeOptions }}',
'{{ arguments }}',
'{{ returnTableType }}',
'{{ remoteFunctionOptions }}',
'{{ securityMode }}',
'{{ definitionBody }}',
'{{ routineReference }}',
'{{ importedLibraries }}',
'{{ dataGovernanceType }}',
'{{ language }}',
'{{ description }}',
'{{ determinismLevel }}',
'{{ pythonOptions }}',
'{{ routineType }}',
'{{ projectId }}',
'{{ +datasetId }}'
RETURNING
arguments,
buildStatus,
creationTime,
dataGovernanceType,
definitionBody,
description,
determinismLevel,
etag,
externalRuntimeOptions,
importedLibraries,
language,
lastModifiedTime,
pythonOptions,
remoteFunctionOptions,
returnTableType,
returnType,
routineReference,
routineType,
securityMode,
sparkOptions,
strictMode
;
# Description fields are for documentation purposes
- name: routines
props:
- name: projectId
value: "{{ projectId }}"
description: Required parameter for the routines resource.
- name: +datasetId
value: "{{ +datasetId }}"
description: Required parameter for the routines resource.
- name: strictMode
value: {{ strictMode }}
description: |
Optional. Use this option to catch many common errors. Error checking is not exhaustive, and successfully creating a procedure doesn't guarantee that the procedure will successfully execute at runtime. If `strictMode` is set to `TRUE`, the procedure body is further checked for errors such as non-existent tables or columns. The `CREATE PROCEDURE` statement fails if the body fails any of these checks. If `strictMode` is set to `FALSE`, the procedure body is checked only for syntax. For procedures that invoke themselves recursively, specify `strictMode=FALSE` to avoid non-existent procedure errors during validation. Default value is `TRUE`.
- name: sparkOptions
description: |
Optional. Spark specific options.
value:
jarUris:
- "{{ jarUris }}"
containerImage: "{{ containerImage }}"
properties: "{{ properties }}"
runtimeVersion: "{{ runtimeVersion }}"
fileUris:
- "{{ fileUris }}"
mainClass: "{{ mainClass }}"
connection: "{{ connection }}"
mainFileUri: "{{ mainFileUri }}"
archiveUris:
- "{{ archiveUris }}"
pyFileUris:
- "{{ pyFileUris }}"
- name: returnType
description: |
Optional if language = "SQL"; required otherwise. Cannot be set if routine_type = "TABLE_VALUED_FUNCTION". If absent, the return type is inferred from definition_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. For example, for the functions created with the following statements: * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);` * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));` * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));` The return_type is `{type_kind: "FLOAT64"}` for `Add` and `Decrement`, and is absent for `Increment` (inferred as FLOAT64 at query time). Suppose the function `Add` is replaced by `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);` Then the inferred return type of `Increment` is automatically changed to INT64 at query time, while the return type of `Decrement` remains FLOAT64.
value:
arrayElementType:
arrayElementType:
arrayElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
- name: externalRuntimeOptions
description: |
Optional. Options for the runtime of the external system executing the routine. This field is only applicable for Python UDFs. [Preview](https://cloud.google.com/products/#product-launch-stages)
value:
maxBatchingRows: "{{ maxBatchingRows }}"
runtimeVersion: "{{ runtimeVersion }}"
containerCpu: {{ containerCpu }}
containerRequestConcurrency: "{{ containerRequestConcurrency }}"
runtimeConnection: "{{ runtimeConnection }}"
containerMemory: "{{ containerMemory }}"
- name: arguments
description: |
Optional.
value:
- tableType:
columns:
- name: "{{ name }}"
type:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
isAggregate: {{ isAggregate }}
mode: "{{ mode }}"
dataType:
arrayElementType:
arrayElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
name: "{{ name }}"
argumentKind: "{{ argumentKind }}"
- name: returnTableType
description: |
Optional. Can be set only if routine_type = "TABLE_VALUED_FUNCTION". If absent, the return table type is inferred from definition_body at query time in each query that references this routine. If present, then the columns in the evaluated table result will be cast to match the column types specified in return table type, at query time.
value:
columns:
- name: "{{ name }}"
type:
arrayElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
rangeElementType:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
structType:
fields: "{{ fields }}"
typeKind: "{{ typeKind }}"
structType:
fields:
- name: "{{ name }}"
type:
arrayElementType: "{{ arrayElementType }}"
rangeElementType: "{{ rangeElementType }}"
structType: "{{ structType }}"
typeKind: "{{ typeKind }}"
typeKind: "{{ typeKind }}"
- name: remoteFunctionOptions
description: |
Optional. Remote function specific options.
value:
connection: "{{ connection }}"
userDefinedContext: "{{ userDefinedContext }}"
endpoint: "{{ endpoint }}"
maxBatchingRows: "{{ maxBatchingRows }}"
- name: securityMode
value: "{{ securityMode }}"
description: |
Optional. The security mode of the routine, if defined. If not defined, the security mode is automatically determined from the routine's configuration.
valid_values: ['SECURITY_MODE_UNSPECIFIED', 'DEFINER', 'INVOKER']
- name: definitionBody
value: "{{ definitionBody }}"
description: |
Required. The body of the routine. For functions, this is the expression in the AS clause. If `language = "SQL"`, it is the substring inside (but excluding) the parentheses. For example, for the function created with the following statement: `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "n", y))` The definition_body is `concat(x, "n", y)` (n is not replaced with linebreak). If `language="JAVASCRIPT"`, it is the evaluated string in the AS clause. For example, for the function created with the following statement: `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "n";n'` The definition_body is `return "n";n` Note that both n are replaced with linebreaks. If `definition_body` references another routine, then that routine must be fully qualified with its project ID.
- name: routineReference
description: |
Required. Reference describing the ID of this routine.
value:
routineId: "{{ routineId }}"
datasetId: "{{ datasetId }}"
projectId: "{{ projectId }}"
- name: importedLibraries
value:
- "{{ importedLibraries }}"
description: |
Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries.
- name: dataGovernanceType
value: "{{ dataGovernanceType }}"
description: |
Optional. If set to `DATA_MASKING`, the function is validated and made available as a masking function. For more information, see [Create custom masking routines](https://cloud.google.com/bigquery/docs/user-defined-functions#custom-mask).
valid_values: ['DATA_GOVERNANCE_TYPE_UNSPECIFIED', 'DATA_MASKING']
- name: language
value: "{{ language }}"
description: |
Optional. Defaults to "SQL" if remote_function_options field is absent, not set otherwise.
valid_values: ['LANGUAGE_UNSPECIFIED', 'SQL', 'JAVASCRIPT', 'PYTHON', 'JAVA', 'SCALA']
- name: description
value: "{{ description }}"
description: |
Optional. The description of the routine, if defined.
- name: determinismLevel
value: "{{ determinismLevel }}"
description: |
Optional. The determinism level of the JavaScript UDF, if defined.
valid_values: ['DETERMINISM_LEVEL_UNSPECIFIED', 'DETERMINISTIC', 'NOT_DETERMINISTIC']
- name: pythonOptions
description: |
Optional. Options for the Python UDF. [Preview](https://cloud.google.com/products/#product-launch-stages)
value:
packages:
- "{{ packages }}"
entryPoint: "{{ entryPoint }}"
- name: routineType
value: "{{ routineType }}"
description: |
Required. The type of routine.
valid_values: ['ROUTINE_TYPE_UNSPECIFIED', 'SCALAR_FUNCTION', 'PROCEDURE', 'TABLE_VALUED_FUNCTION', 'AGGREGATE_FUNCTION']
REPLACE examples
- update
Updates information in an existing routine. The update method replaces the entire Routine resource. # IAM Permissions Requires the bigquery.routines.update permission on the routine.
REPLACE google.bigquery.routines
SET
data__strictMode = {{ strictMode }},
data__sparkOptions = '{{ sparkOptions }}',
data__returnType = '{{ returnType }}',
data__externalRuntimeOptions = '{{ externalRuntimeOptions }}',
data__arguments = '{{ arguments }}',
data__returnTableType = '{{ returnTableType }}',
data__remoteFunctionOptions = '{{ remoteFunctionOptions }}',
data__securityMode = '{{ securityMode }}',
data__definitionBody = '{{ definitionBody }}',
data__routineReference = '{{ routineReference }}',
data__importedLibraries = '{{ importedLibraries }}',
data__dataGovernanceType = '{{ dataGovernanceType }}',
data__language = '{{ language }}',
data__description = '{{ description }}',
data__determinismLevel = '{{ determinismLevel }}',
data__pythonOptions = '{{ pythonOptions }}',
data__routineType = '{{ routineType }}'
WHERE
projectId = '{{ projectId }}' --required
AND +datasetId = '{{ +datasetId }}' --required
AND +routineId = '{{ +routineId }}' --required
RETURNING
arguments,
buildStatus,
creationTime,
dataGovernanceType,
definitionBody,
description,
determinismLevel,
etag,
externalRuntimeOptions,
importedLibraries,
language,
lastModifiedTime,
pythonOptions,
remoteFunctionOptions,
returnTableType,
returnType,
routineReference,
routineType,
securityMode,
sparkOptions,
strictMode;
DELETE examples
- delete
Deletes the routine specified by routineId from the dataset. # IAM Permissions Requires the bigquery.routines.delete permission on the routine.
DELETE FROM google.bigquery.routines
WHERE projectId = '{{ projectId }}' --required
AND +datasetId = '{{ +datasetId }}' --required
AND +routineId = '{{ +routineId }}' --required
;