routines

POST /projects/{projectsId}/datasets/{datasetsId}/routines

Changed on

Creates a new routine in the dataset. # IAM Permissions Requires the bigquery.routines.create permission on the dataset.

Request

  • Base URL
    https://bigquery.googleapis.com/bigquery/v2
  • Auth
    • OAuth 2 and OAuth 2
      Implicit: https://accounts.google.com/o/oauth2/auth
      Scopes: https://www.googleapis.com/auth/bigquery
      Authorization code: https://accounts.google.com/o/oauth2/auth
      Token URL: https://accounts.google.com/o/oauth2/token scopes: https://www.googleapis.com/auth/bigquery
    • or OAuth 2 and OAuth 2
      Implicit: https://accounts.google.com/o/oauth2/auth
      Scopes: https://www.googleapis.com/auth/cloud-platform
      Authorization code: https://accounts.google.com/o/oauth2/auth
      Token URL: https://accounts.google.com/o/oauth2/token scopes: https://www.googleapis.com/auth/cloud-platform

Path parameters

projectsIdstring required
datasetsIdstring required

Request body

creationTimestring int64

Output only. The time when this routine was created, in milliseconds since the epoch.

dataGovernanceType'DATA_GOVERNANCE_TYPE_UNSPECIFIED' | 'DATA_MASKING'

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.

definitionBodystring

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.

descriptionstring

Optional. The description of the routine, if defined.

determinismLevel'DETERMINISM_LEVEL_UNSPECIFIED' | 'DETERMINISTIC' | 'NOT_DETERMINISTIC'

Optional. The determinism level of the JavaScript UDF, if defined.

etagstring

Output only. A hash of this resource.

importedLibrariesstring[]

Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries.

language'LANGUAGE_UNSPECIFIED' | 'SQL' | 'JAVASCRIPT' | 'PYTHON' | 'JAVA' | 'SCALA'

Optional. Defaults to "SQL" if remote_function_options field is absent, not set otherwise.

lastModifiedTimestring int64

Output only. The time when this routine was last modified, in milliseconds since the epoch.

routineType'ROUTINE_TYPE_UNSPECIFIED' | 'SCALAR_FUNCTION' | 'PROCEDURE' | 'TABLE_VALUED_FUNCTION' | 'AGGREGATE_FUNCTION'

Required. The type of routine.

securityMode'SECURITY_MODE_UNSPECIFIED' | 'DEFINER' | 'INVOKER'

Optional. The security mode of the routine, if defined. If not defined, the security mode is automatically determined from the routine's configuration.

strictModeboolean

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.

Response

Successful response

creationTimestring int64

Output only. The time when this routine was created, in milliseconds since the epoch.

dataGovernanceType'DATA_GOVERNANCE_TYPE_UNSPECIFIED' | 'DATA_MASKING'

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.

definitionBodystring

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.

descriptionstring

Optional. The description of the routine, if defined.

determinismLevel'DETERMINISM_LEVEL_UNSPECIFIED' | 'DETERMINISTIC' | 'NOT_DETERMINISTIC'

Optional. The determinism level of the JavaScript UDF, if defined.

etagstring

Output only. A hash of this resource.

importedLibrariesstring[]

Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries.

language'LANGUAGE_UNSPECIFIED' | 'SQL' | 'JAVASCRIPT' | 'PYTHON' | 'JAVA' | 'SCALA'

Optional. Defaults to "SQL" if remote_function_options field is absent, not set otherwise.

lastModifiedTimestring int64

Output only. The time when this routine was last modified, in milliseconds since the epoch.

routineType'ROUTINE_TYPE_UNSPECIFIED' | 'SCALAR_FUNCTION' | 'PROCEDURE' | 'TABLE_VALUED_FUNCTION' | 'AGGREGATE_FUNCTION'

Required. The type of routine.

securityMode'SECURITY_MODE_UNSPECIFIED' | 'DEFINER' | 'INVOKER'

Optional. The security mode of the routine, if defined. If not defined, the security mode is automatically determined from the routine's configuration.

strictModeboolean

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.

Changes

    • info

      the security scope https://www.googleapis.com/auth/bigquery was added to the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/bigquery was added to the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/cloud-platform was removed from the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/cloud-platform was removed from the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/bigquery was added to the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/bigquery was added to the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/cloud-platform was removed from the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/cloud-platform was removed from the endpoint's security scheme Oauth2c