1.64.1 (latest) 1.64.0 1.63.1 1.62.0 1.61.1 1.60.0 1.59.0 1.58.0 1.57.0 1.56.0 1.55.0 1.54.0 1.53.0 1.52.1 1.51.1 1.50.0 1.49.1 1.48.1 1.47.0 1.46.1 1.45.0 1.44.2 1.43.1 1.42.0 1.41.0 1.40.0 1.39.0 1.38.1 Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::Routine::Updater.

Yielded to a block to accumulate changes. See [Dataset#create_routine](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Dataset#Google__Cloud__Bigquery__Dataset_create_routine_instance_ "Google::Cloud::Bigquery::Dataset#create_routine (method)") and [#update](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine#Google__Cloud__Bigquery__Routine_update_instance_ "Google::Cloud::Bigquery::Routine#update (method)").

## Inherits

- [Google::Cloud::Bigquery::Routine](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine)

## Examples

Creating a new routine:

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"

routine = dataset.create_routine "my_routine" do |r|
  r.routine_type = "SCALAR_FUNCTION"
  r.language = "SQL"
  r.arguments = [
    Google::Cloud::Bigquery::Argument.new(name: "x", data_type: "INT64")
  ]
  r.body = "x * 3"
  r.description = "My routine description"
end

puts routine.routine_id
```

Updating an existing routine:

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
routine = dataset.routine "my_routine"

routine.update do |r|
  r.body = "x * 4"
  r.description = "My new routine description"
end
```

## Methods

### #arguments=

    def arguments=(new_arguments)

Updates the input/output arguments of the routine. Optional.
**Parameter**

- **new_arguments** (Array\<[Argument](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Argument)\>) --- The new arguments.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
routine = dataset.routine "my_routine"

routine.arguments = [
  Google::Cloud::Bigquery::Argument.new(name: "x", data_type: "INT64")
]
```

### #body=

    def body=(new_body)

Updates the body of the routine. Required.


For functions ([#scalar_function?](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine#Google__Cloud__Bigquery__Routine_scalar_function__instance_ "Google::Cloud::Bigquery::Routine#scalar_function? (method)")), this is the expression in the `AS` clause.

When the routine is a SQL function ([#sql?](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine#Google__Cloud__Bigquery__Routine_sql__instance_ "Google::Cloud::Bigquery::Routine#sql? (method)")), 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).

<br />

When the routine is a JavaScript function ([#javascript?](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine#Google__Cloud__Bigquery__Routine_javascript__instance_ "Google::Cloud::Bigquery::Routine#javascript? (method)")), 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 &quot;\n&quot;;\n"`
``
Note that both `\n` are replaced with linebreaks.
**Parameter**

- **new_body** (String) --- The new body of the routine.

### #data_governance_type=

    def data_governance_type=(new_data_governance_type)

Updates the data governance type of the routine. Optional.


<br />

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).
**Parameter**

- **new_data_governance_type** (String, nil) --- The new data governance type. `nil` to unset.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
routine = dataset.routine "my_routine"

routine.data_governance_type = "DATA_MASKING"
```

### #delete

    def delete()

### #description=

    def description=(new_description)

Updates the description of the routine. Optional. \[Experimental\]
**Parameter**

- **new_description** (String) --- The new routine description.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
routine = dataset.routine "my_routine"

routine.description #=> "My routine description"
routine.update do |r|
  r.description = "My updated routine description"
end
```

### #determinism_level=

    def determinism_level=(new_determinism_level)

Updates the JavaScript UDF determinism level. Optional.

- `DETERMINISTIC` - Deterministic indicates that two calls with the same input to a UDF yield the same output. If all JavaScript UDFs are `DETERMINISTIC`, the query result is potentially cachable.
- `NOT_DETERMINISTIC` - Not deterministic indicates that the output of the UDF is not guaranteed to yield the same output each time for a given set of inputs. If any JavaScript UDF is `NOT_DETERMINISTIC`, the query result is not cacheable.
**Parameter**

- **new_determinism_level** (String, nil) --- The new routine determinism level in upper case.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
routine = dataset.routine "my_routine"

routine.determinism_level #=> "NOT_DETERMINISTIC"
routine.update do |r|
  r.determinism_level = "DETERMINISTIC"
end
```

### #imported_libraries=

    def imported_libraries=(new_imported_libraries)

Updates the list of the Google Cloud Storage URIs of imported JavaScript libraries. Optional. Only used if
[#language](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine#Google__Cloud__Bigquery__Routine_language_instance_ "Google::Cloud::Bigquery::Routine#language (method)") is `JAVASCRIPT` ([#javascript?](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine#Google__Cloud__Bigquery__Routine_javascript__instance_ "Google::Cloud::Bigquery::Routine#javascript? (method)")).
**Parameter**

- **new_imported_libraries** (Array\<String\>, nil) --- An array of Google Cloud Storage URIs, e.g. `["gs://cloud-samples-data/bigquery/udfs/max-value.js"]`.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
routine = dataset.routine "my_routine"

routine.update do |r|
  r.imported_libraries = [
    "gs://cloud-samples-data/bigquery/udfs/max-value.js"
  ]
end
```

### #language=

    def language=(new_language)

Updates the programming language of routine. Optional. Defaults to "SQL".

- `SQL` - SQL language.
- `JAVASCRIPT` - JavaScript language.
**Parameter**

- **new_language** (String) --- The new language in upper case.

### #refresh!

    def refresh!()

**Alias Of** : [#reload!](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine-Updater#Google__Cloud__Bigquery__Routine__Updater_reload!_instance_)

### #reload!

    def reload!()

**Aliases**

- [#refresh!](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine-Updater#Google__Cloud__Bigquery__Routine__Updater_refresh!_instance_)

### #remote_function_options=

    def remote_function_options=(new_remote_function_options)

Updates the remote function specific options. Optional.
**Parameter**

- **new_remote_function_options** ([Google::Cloud::Bigquery::RemoteFunctionOptions](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-RemoteFunctionOptions)) --- The new remote function options.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
routine = dataset.routine "my_routine"

routine.update do |r|
  rfo = Google::Cloud::Bigquery::RemoteFunctionOptions.new
  rfo.endpoint = "https://us-east1-my_gcf_project.cloudfunctions.net/remote_add"
  rfo.connection = "projects/my-project/locations/us-east1/connections/my-connection"
  r.remote_function_options = rfo
end
```

### #return_type=

    def return_type=(new_return_type)

Updates the return type of the routine. Optional if the routine is a SQL function ([#sql?](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine#Google__Cloud__Bigquery__Routine_sql__instance_ "Google::Cloud::Bigquery::Routine#sql? (method)")); required
otherwise.


If absent, the return type is inferred from [#body](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine#Google__Cloud__Bigquery__Routine_body_instance_ "Google::Cloud::Bigquery::Routine#body (method)") 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 returnType is `{typeKind: "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);`

<br />

Then the inferred return type of Increment is automatically changed to `INT64` at query time, while the
return type of Decrement remains `FLOAT64`.
**Parameter**

- **new_return_type** ([Google::Cloud::Bigquery::StandardSql::DataType](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-StandardSql-DataType), String) --- The new return type for the routine.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
routine = dataset.routine "my_routine"

routine.return_type.type_kind #=> "INT64"
routine.update do |r|
  r.return_type = "STRING"
end
```

### #routine_type=

    def routine_type=(new_routine_type)

Updates the type of routine. Required.

- `SCALAR_FUNCTION` - Non-builtin permanent scalar function.
- `PROCEDURE` - Stored procedure.
**Parameter**

- **new_routine_type** (String) --- The new type of the routine.

### #update

    def update()