Resource: Routine
A user-defined function or a stored procedure.
JSON representation | |
---|---|
{ "etag": string, "routineReference": { object ( |
Fields | |
---|---|
etag |
Output only. A hash of this resource. |
routineReference |
Required. Reference describing the ID of this routine. |
routineType |
Required. The type of routine. |
creationTime |
Output only. The time when this routine was created, in milliseconds since the epoch. |
lastModifiedTime |
Output only. The time when this routine was last modified, in milliseconds since the epoch. |
language |
Optional. Defaults to "SQL". |
arguments[] |
Optional. |
returnType |
Optional if language = "SQL"; required otherwise. If absent, the return type is inferred from definitionBody 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:
The returnType is Suppose the function Then the inferred return type of |
importedLibraries[] |
Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries. |
definitionBody |
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:
The definitionBody is If language=JAVASCRIPT, it is the evaluated string in the AS clause. For example, for the function created with the following statement:
The definitionBody is
Note that both \n are replaced with linebreaks. |
description |
Optional. [Experimental] The description of the routine if defined. |
RoutineReference
Id path of a routine.
JSON representation | |
---|---|
{ "projectId": string, "datasetId": string, "routineId": string } |
Fields | |
---|---|
projectId |
Required. The ID of the project containing this routine. |
datasetId |
Required. The ID of the dataset containing this routine. |
routineId |
Required. The ID of the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters. |
RoutineType
The fine-grained type of the routine.
Enums | |
---|---|
ROUTINE_TYPE_UNSPECIFIED |
|
SCALAR_FUNCTION |
Non-builtin permanent scalar function. |
PROCEDURE |
Stored procedure. |
Language
The language of the routine.
Enums | |
---|---|
LANGUAGE_UNSPECIFIED |
|
SQL |
SQL language. |
JAVASCRIPT |
JavaScript language. |
Argument
Input/output argument of a function or a stored procedure.
JSON representation | |
---|---|
{ "name": string, "argumentKind": enum ( |
Fields | |
---|---|
name |
Optional. The name of this argument. Can be absent for function return argument. |
argumentKind |
Optional. Defaults to FIXED_TYPE. |
mode |
Optional. Specifies whether the argument is input or output. Can be set for procedures only. |
dataType |
Required unless argumentKind = ANY_TYPE. |
ArgumentKind
Enums | |
---|---|
ARGUMENT_KIND_UNSPECIFIED |
|
FIXED_TYPE |
The argument is a variable with fully specified type, which can be a struct or an array, but not a table. |
ANY_TYPE |
The argument is any type, including struct or array, but not a table. To be added: FIXED_TABLE, ANY_TABLE |
Mode
The input/output mode of the argument.
Enums | |
---|---|
MODE_UNSPECIFIED |
|
IN |
The argument is input-only. |
OUT |
The argument is output-only. |
INOUT |
The argument is both an input and an output. |
Methods |
|
---|---|
|
Deletes the routine specified by routineId from the dataset. |
|
Gets the specified routine resource by routine ID. |
|
Creates a new routine in the dataset. |
|
Lists all routines in the specified dataset. |
|
Updates information in an existing routine. |