---
title: "PUT /projects/{+projectId}/datasets/{+datasetId}/routines/{+routineId}"
method: PUT
path: "/projects/{+projectId}/datasets/{+datasetId}/routines/{+routineId}"
tags: ["routines"]
---

# PUT /projects/{+projectId}/datasets/{+datasetId}/routines/{+routineId}

`PUT /projects/{+projectId}/datasets/{+datasetId}/routines/{+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.

## Path parameters

- `projectId` string, required
- `datasetId` string, required
- `routineId` string, required

## Request body

- Routine — A user-defined function or a stored procedure.
  - `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](https://cloud.google.com/bigquery/docs/user-defined-functions#custom-mask).
  - `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.
  - `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`.
  - `determinismLevel` 'DETERMINISM_LEVEL_UNSPECIFIED' | 'DETERMINISTIC' | 'NOT_DETERMINISTIC' — Optional. The determinism level of the JavaScript UDF, if defined.
  - `description` string — Optional. The description of the routine, if defined.
  - `language` 'LANGUAGE_UNSPECIFIED' | 'SQL' | 'JAVASCRIPT' | 'PYTHON' | 'JAVA' | 'SCALA' — Optional. Defaults to "SQL" if remote_function_options field is absent, not set otherwise.
  - `returnTableType` StandardSqlTableType — A table type
    - `columns` StandardSqlField[] — The columns in this table type
      - `name` string — Optional. The name of this field. Can be absent for struct fields.
      - `type` StandardSqlDataType — The data type of a variable such as a function argument. Examples include: * INT64: `{"typeKind": "INT64"}` * ARRAY: { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "STRING"} } * STRUCT>: { "typeKind": "STRUCT", "structType": { "fields": [ { "name": "x", "type": {"typeKind": "STRING"} }, { "name": "y", "type": { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "DATE"} } } ] } } * RANGE: { "typeKind": "RANGE", "rangeElementType": {"typeKind": "DATE"} }
        - `arrayElementType` StandardSqlDataType — recursive
        - `rangeElementType` StandardSqlDataType — recursive
        - `structType` StandardSqlStructType — The representation of a SQL STRUCT type.
          - `fields` StandardSqlField[] — Fields within the struct.
        - `typeKind` 'TYPE_KIND_UNSPECIFIED' | 'INT64' | 'BOOL' | 'FLOAT64' | 'STRING' | 'BYTES' | 'TIMESTAMP' | 'DATE' | 'TIME' | 'DATETIME' | 'INTERVAL' | 'GEOGRAPHY' | 'NUMERIC' | 'BIGNUMERIC' | 'JSON' | 'ARRAY' | 'STRUCT' | 'RANGE' — Required. The top level type of this field. Can be any GoogleSQL data type (e.g., "INT64", "DATE", "ARRAY").
  - `pythonOptions` PythonOptions — Options for a user-defined Python function.
    - `entryPoint` string — Required. The name of the function defined in Python code as the entry point when the Python UDF is invoked.
    - `packages` string[] — Optional. A list of Python package names along with versions to be installed. Example: ["pandas>=2.1", "google-cloud-translate==3.11"]. For more information, see [Use third-party packages](https://cloud.google.com/bigquery/docs/user-defined-functions-python#third-party-packages).
  - `etag` string — Output only. A hash of this resource.
  - `remoteFunctionOptions` RemoteFunctionOptions — Options for a remote user-defined function.
    - `maxBatchingRows` string, int64 — Max number of rows in each batch sent to the remote service. If absent or if 0, BigQuery dynamically decides the number of rows in a batch.
    - `connection` string — Fully qualified name of the user-provided connection object which holds the authentication information to send requests to the remote service. Format: ```"projects/{projectId}/locations/{locationId}/connections/{connectionId}"```
    - `endpoint` string — Endpoint of the user-provided remote service, e.g. ```https://us-east1-my_gcf_project.cloudfunctions.net/remote_add```
    - `userDefinedContext` object — User-defined context as a set of key/value pairs, which will be sent as function invocation context together with batched arguments in the requests to the remote service. The total number of bytes of keys and values must be less than 8KB.
  - `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.
  - `routineReference` RoutineReference — Id path of a routine.
    - `datasetId` string — Required. The ID of the dataset containing this routine.
    - `routineId` string — 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.
    - `projectId` string — Required. The ID of the project containing this routine.
  - `returnType` StandardSqlDataType — The data type of a variable such as a function argument. Examples include: * INT64: `{"typeKind": "INT64"}` * ARRAY: { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "STRING"} } * STRUCT>: { "typeKind": "STRUCT", "structType": { "fields": [ { "name": "x", "type": {"typeKind": "STRING"} }, { "name": "y", "type": { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "DATE"} } } ] } } * RANGE: { "typeKind": "RANGE", "rangeElementType": {"typeKind": "DATE"} }
    - `arrayElementType` StandardSqlDataType — recursive
    - `rangeElementType` StandardSqlDataType — recursive
    - `structType` StandardSqlStructType — The representation of a SQL STRUCT type.
      - `fields` StandardSqlField[] — Fields within the struct.
        - `name` string — Optional. The name of this field. Can be absent for struct fields.
        - `type` StandardSqlDataType — recursive
    - `typeKind` 'TYPE_KIND_UNSPECIFIED' | 'INT64' | 'BOOL' | 'FLOAT64' | 'STRING' | 'BYTES' | 'TIMESTAMP' | 'DATE' | 'TIME' | 'DATETIME' | 'INTERVAL' | 'GEOGRAPHY' | 'NUMERIC' | 'BIGNUMERIC' | 'JSON' | 'ARRAY' | 'STRUCT' | 'RANGE' — Required. The top level type of this field. Can be any GoogleSQL data type (e.g., "INT64", "DATE", "ARRAY").
  - `buildStatus` RoutineBuildStatus — The status of a routine build.
    - `buildState` 'BUILD_STATE_UNSPECIFIED' | 'IN_PROGRESS' | 'SUCCEEDED' | 'FAILED' — Output only. The current build state of the routine.
    - `imageSizeBytes` string, int64 — Output only. The size of the image in bytes. Populated only after the build succeeds.
    - `buildDuration` string, google-duration — Output only. The time taken for the image build. Populated only after the build succeeds or fails.
    - `errorResult` ErrorProto — Error details.
      - `debugInfo` string — Debugging information. This property is internal to Google and should not be used.
      - `reason` string — A short error code that summarizes the error.
      - `message` string — A human-readable description of the error.
      - `location` string — Specifies where the error occurred, if present.
    - `buildStateUpdateTime` string, google-datetime — Output only. The time when the build state was updated last.
  - `lastModifiedTime` string, int64 — Output only. The time when this routine was last modified, in milliseconds since the epoch.
  - `sparkOptions` SparkOptions — Options for a user-defined Spark routine.
    - `containerImage` string — Custom container image for the runtime environment.
    - `jarUris` string[] — JARs to include on the driver and executor CLASSPATH. For more information about Apache Spark, see [Apache Spark](https://spark.apache.org/docs/latest/index.html).
    - `connection` string — Fully qualified name of the user-provided Spark connection object. Format: ```"projects/{project_id}/locations/{location_id}/connections/{connection_id}"```
    - `pyFileUris` string[] — Python files to be placed on the PYTHONPATH for PySpark application. Supported file types: `.py`, `.egg`, and `.zip`. For more information about Apache Spark, see [Apache Spark](https://spark.apache.org/docs/latest/index.html).
    - `fileUris` string[] — Files to be placed in the working directory of each executor. For more information about Apache Spark, see [Apache Spark](https://spark.apache.org/docs/latest/index.html).
    - `properties` object — Configuration properties as a set of key/value pairs, which will be passed on to the Spark application. For more information, see [Apache Spark](https://spark.apache.org/docs/latest/index.html) and the [procedure option list](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#procedure_option_list).
    - `mainClass` string — The fully qualified name of a class in jar_uris, for example, com.example.wordcount. Exactly one of main_class and main_jar_uri field should be set for Java/Scala language type.
    - `archiveUris` string[] — Archive files to be extracted into the working directory of each executor. For more information about Apache Spark, see [Apache Spark](https://spark.apache.org/docs/latest/index.html).
    - `mainFileUri` string — The main file/jar URI of the Spark application. Exactly one of the definition_body field and the main_file_uri field must be set for Python. Exactly one of main_class and main_file_uri field should be set for Java/Scala language type.
    - `runtimeVersion` string — Runtime version. If not specified, the default runtime version is used.
  - `importedLibraries` string[] — Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries.
  - `arguments` Argument[] — Optional.
    - `dataType` StandardSqlDataType — The data type of a variable such as a function argument. Examples include: * INT64: `{"typeKind": "INT64"}` * ARRAY: { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "STRING"} } * STRUCT>: { "typeKind": "STRUCT", "structType": { "fields": [ { "name": "x", "type": {"typeKind": "STRING"} }, { "name": "y", "type": { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "DATE"} } } ] } } * RANGE: { "typeKind": "RANGE", "rangeElementType": {"typeKind": "DATE"} }
      - `arrayElementType` StandardSqlDataType — recursive
      - `rangeElementType` StandardSqlDataType — recursive
      - `structType` StandardSqlStructType — The representation of a SQL STRUCT type.
        - `fields` StandardSqlField[] — Fields within the struct.
          - `name` string — Optional. The name of this field. Can be absent for struct fields.
          - `type` StandardSqlDataType — recursive
      - `typeKind` 'TYPE_KIND_UNSPECIFIED' | 'INT64' | 'BOOL' | 'FLOAT64' | 'STRING' | 'BYTES' | 'TIMESTAMP' | 'DATE' | 'TIME' | 'DATETIME' | 'INTERVAL' | 'GEOGRAPHY' | 'NUMERIC' | 'BIGNUMERIC' | 'JSON' | 'ARRAY' | 'STRUCT' | 'RANGE' — Required. The top level type of this field. Can be any GoogleSQL data type (e.g., "INT64", "DATE", "ARRAY").
    - `isAggregate` boolean — Optional. Whether the argument is an aggregate function parameter. Must be Unset for routine types other than AGGREGATE_FUNCTION. For AGGREGATE_FUNCTION, if set to false, it is equivalent to adding "NOT AGGREGATE" clause in DDL; Otherwise, it is equivalent to omitting "NOT AGGREGATE" clause in DDL.
    - `argumentKind` 'ARGUMENT_KIND_UNSPECIFIED' | 'FIXED_TYPE' | 'ANY_TYPE' — Optional. Defaults to FIXED_TYPE.
    - `mode` 'MODE_UNSPECIFIED' | 'IN' | 'OUT' | 'INOUT' — Optional. Specifies whether the argument is input or output. Can be set for procedures only.
    - `name` string — Optional. The name of this argument. Can be absent for function return argument.
  - `creationTime` string, int64 — Output only. The time when this routine was created, in milliseconds since the epoch.
  - `externalRuntimeOptions` ExternalRuntimeOptions — Options for the runtime of the external system.
    - `runtimeConnection` string — Optional. Fully qualified name of the connection whose service account will be used to execute the code in the container. Format: ```"projects/{project_id}/locations/{location_id}/connections/{connection_id}"```
    - `maxBatchingRows` string, int64 — Optional. Maximum number of rows in each batch sent to the external runtime. If absent or if 0, BigQuery dynamically decides the number of rows in a batch.
    - `containerMemory` string — Optional. Amount of memory provisioned for a Python UDF container instance. Format: {number}{unit} where unit is one of "M", "G", "Mi" and "Gi" (e.g. 1G, 512Mi). If not specified, the default value is 512Mi. For more information, see [Configure container limits for Python UDFs](https://cloud.google.com/bigquery/docs/user-defined-functions-python#configure-container-limits)
    - `runtimeVersion` string — Optional. Language runtime version. Example: `python-3.11`.
    - `containerCpu` number, double — Optional. Amount of CPU provisioned for a Python UDF container instance. For more information, see [Configure container limits for Python UDFs](https://cloud.google.com/bigquery/docs/user-defined-functions-python#configure-container-limits)
    - `containerRequestConcurrency` string, int64 — Optional. Maximum number of requests that a Python UDF instance can handle concurrently. If absent or if `0`, the default concurrency value is used. For more information, see [Configure container limits for Python UDFs](https://cloud.google.com/bigquery/docs/user-defined-functions-python#configure-container-limits).
  - `routineType` 'ROUTINE_TYPE_UNSPECIFIED' | 'SCALAR_FUNCTION' | 'PROCEDURE' | 'TABLE_VALUED_FUNCTION' | 'AGGREGATE_FUNCTION' — Required. The type of routine.

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/bigquery.md) · [All operations](https://skmtc.net/google/apis/bigquery/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/bigquery/versions/98f33ea9c8c9/schema)
