Skip to main content

Routine

Struct Routine 

Source
#[non_exhaustive]
pub struct Routine {
Show 21 fields pub etag: String, pub routine_reference: Option<RoutineReference>, pub routine_type: RoutineType, pub creation_time: i64, pub last_modified_time: i64, pub language: Language, pub arguments: Vec<Argument>, pub return_type: Option<StandardSqlDataType>, pub return_table_type: Option<StandardSqlTableType>, pub imported_libraries: Vec<String>, pub definition_body: String, pub description: String, pub determinism_level: DeterminismLevel, pub security_mode: SecurityMode, pub strict_mode: Option<BoolValue>, pub remote_function_options: Option<RemoteFunctionOptions>, pub spark_options: Option<SparkOptions>, pub data_governance_type: DataGovernanceType, pub python_options: Option<PythonOptions>, pub external_runtime_options: Option<ExternalRuntimeOptions>, pub build_status: Option<RoutineBuildStatus>, /* private fields */
}
Expand description

A user-defined function or a stored procedure.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§etag: String

Output only. A hash of this resource.

§routine_reference: Option<RoutineReference>

Required. Reference describing the ID of this routine.

§routine_type: RoutineType

Required. The type of routine.

§creation_time: i64

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

§last_modified_time: i64

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

§language: Language

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

§arguments: Vec<Argument>

Optional.

§return_type: Option<StandardSqlDataType>

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.

§return_table_type: Option<StandardSqlTableType>

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.

§imported_libraries: Vec<String>

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

§definition_body: 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.

§determinism_level: DeterminismLevel

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

§security_mode: SecurityMode

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

§strict_mode: Option<BoolValue>

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.

§remote_function_options: Option<RemoteFunctionOptions>

Optional. Remote function specific options.

§spark_options: Option<SparkOptions>

Optional. Spark specific options.

§data_governance_type: DataGovernanceType

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.

§python_options: Option<PythonOptions>

Optional. Options for the Python UDF. Preview

§external_runtime_options: Option<ExternalRuntimeOptions>

Optional. Options for the runtime of the external system executing the routine. This field is only applicable for Python UDFs. Preview

§build_status: Option<RoutineBuildStatus>

Output only. The build status of the routine. This field is only applicable to Python UDFs. Preview

Implementations§

Source§

impl Routine

Source

pub fn new() -> Self

Creates a new default instance.

Source

pub fn set_etag<T: Into<String>>(self, v: T) -> Self

Sets the value of etag.

§Example
let x = Routine::new().set_etag("example");
Source

pub fn set_routine_reference<T>(self, v: T) -> Self

Sets the value of routine_reference.

§Example
use google_cloud_bigquery_v2::model::RoutineReference;
let x = Routine::new().set_routine_reference(RoutineReference::default()/* use setters */);
Source

pub fn set_or_clear_routine_reference<T>(self, v: Option<T>) -> Self

Sets or clears the value of routine_reference.

§Example
use google_cloud_bigquery_v2::model::RoutineReference;
let x = Routine::new().set_or_clear_routine_reference(Some(RoutineReference::default()/* use setters */));
let x = Routine::new().set_or_clear_routine_reference(None::<RoutineReference>);
Source

pub fn set_routine_type<T: Into<RoutineType>>(self, v: T) -> Self

Sets the value of routine_type.

§Example
use google_cloud_bigquery_v2::model::routine::RoutineType;
let x0 = Routine::new().set_routine_type(RoutineType::ScalarFunction);
let x1 = Routine::new().set_routine_type(RoutineType::Procedure);
let x2 = Routine::new().set_routine_type(RoutineType::TableValuedFunction);
Source

pub fn set_creation_time<T: Into<i64>>(self, v: T) -> Self

Sets the value of creation_time.

§Example
let x = Routine::new().set_creation_time(42);
Source

pub fn set_last_modified_time<T: Into<i64>>(self, v: T) -> Self

Sets the value of last_modified_time.

§Example
let x = Routine::new().set_last_modified_time(42);
Source

pub fn set_language<T: Into<Language>>(self, v: T) -> Self

Sets the value of language.

§Example
use google_cloud_bigquery_v2::model::routine::Language;
let x0 = Routine::new().set_language(Language::Sql);
let x1 = Routine::new().set_language(Language::Javascript);
let x2 = Routine::new().set_language(Language::Python);
Source

pub fn set_arguments<T, V>(self, v: T) -> Self
where T: IntoIterator<Item = V>, V: Into<Argument>,

Sets the value of arguments.

§Example
use google_cloud_bigquery_v2::model::routine::Argument;
let x = Routine::new()
    .set_arguments([
        Argument::default()/* use setters */,
        Argument::default()/* use (different) setters */,
    ]);
Source

pub fn set_return_type<T>(self, v: T) -> Self

Sets the value of return_type.

§Example
use google_cloud_bigquery_v2::model::StandardSqlDataType;
let x = Routine::new().set_return_type(StandardSqlDataType::default()/* use setters */);
Source

pub fn set_or_clear_return_type<T>(self, v: Option<T>) -> Self

Sets or clears the value of return_type.

§Example
use google_cloud_bigquery_v2::model::StandardSqlDataType;
let x = Routine::new().set_or_clear_return_type(Some(StandardSqlDataType::default()/* use setters */));
let x = Routine::new().set_or_clear_return_type(None::<StandardSqlDataType>);
Source

pub fn set_return_table_type<T>(self, v: T) -> Self

Sets the value of return_table_type.

§Example
use google_cloud_bigquery_v2::model::StandardSqlTableType;
let x = Routine::new().set_return_table_type(StandardSqlTableType::default()/* use setters */);
Source

pub fn set_or_clear_return_table_type<T>(self, v: Option<T>) -> Self

Sets or clears the value of return_table_type.

§Example
use google_cloud_bigquery_v2::model::StandardSqlTableType;
let x = Routine::new().set_or_clear_return_table_type(Some(StandardSqlTableType::default()/* use setters */));
let x = Routine::new().set_or_clear_return_table_type(None::<StandardSqlTableType>);
Source

pub fn set_imported_libraries<T, V>(self, v: T) -> Self
where T: IntoIterator<Item = V>, V: Into<String>,

Sets the value of imported_libraries.

§Example
let x = Routine::new().set_imported_libraries(["a", "b", "c"]);
Source

pub fn set_definition_body<T: Into<String>>(self, v: T) -> Self

Sets the value of definition_body.

§Example
let x = Routine::new().set_definition_body("example");
Source

pub fn set_description<T: Into<String>>(self, v: T) -> Self

Sets the value of description.

§Example
let x = Routine::new().set_description("example");
Source

pub fn set_determinism_level<T: Into<DeterminismLevel>>(self, v: T) -> Self

Sets the value of determinism_level.

§Example
use google_cloud_bigquery_v2::model::routine::DeterminismLevel;
let x0 = Routine::new().set_determinism_level(DeterminismLevel::Deterministic);
let x1 = Routine::new().set_determinism_level(DeterminismLevel::NotDeterministic);
Source

pub fn set_security_mode<T: Into<SecurityMode>>(self, v: T) -> Self

Sets the value of security_mode.

§Example
use google_cloud_bigquery_v2::model::routine::SecurityMode;
let x0 = Routine::new().set_security_mode(SecurityMode::Definer);
let x1 = Routine::new().set_security_mode(SecurityMode::Invoker);
Source

pub fn set_strict_mode<T>(self, v: T) -> Self
where T: Into<BoolValue>,

Sets the value of strict_mode.

§Example
use wkt::BoolValue;
let x = Routine::new().set_strict_mode(BoolValue::default()/* use setters */);
Source

pub fn set_or_clear_strict_mode<T>(self, v: Option<T>) -> Self
where T: Into<BoolValue>,

Sets or clears the value of strict_mode.

§Example
use wkt::BoolValue;
let x = Routine::new().set_or_clear_strict_mode(Some(BoolValue::default()/* use setters */));
let x = Routine::new().set_or_clear_strict_mode(None::<BoolValue>);
Source

pub fn set_remote_function_options<T>(self, v: T) -> Self

Sets the value of remote_function_options.

§Example
use google_cloud_bigquery_v2::model::routine::RemoteFunctionOptions;
let x = Routine::new().set_remote_function_options(RemoteFunctionOptions::default()/* use setters */);
Source

pub fn set_or_clear_remote_function_options<T>(self, v: Option<T>) -> Self

Sets or clears the value of remote_function_options.

§Example
use google_cloud_bigquery_v2::model::routine::RemoteFunctionOptions;
let x = Routine::new().set_or_clear_remote_function_options(Some(RemoteFunctionOptions::default()/* use setters */));
let x = Routine::new().set_or_clear_remote_function_options(None::<RemoteFunctionOptions>);
Source

pub fn set_spark_options<T>(self, v: T) -> Self
where T: Into<SparkOptions>,

Sets the value of spark_options.

§Example
use google_cloud_bigquery_v2::model::SparkOptions;
let x = Routine::new().set_spark_options(SparkOptions::default()/* use setters */);
Source

pub fn set_or_clear_spark_options<T>(self, v: Option<T>) -> Self
where T: Into<SparkOptions>,

Sets or clears the value of spark_options.

§Example
use google_cloud_bigquery_v2::model::SparkOptions;
let x = Routine::new().set_or_clear_spark_options(Some(SparkOptions::default()/* use setters */));
let x = Routine::new().set_or_clear_spark_options(None::<SparkOptions>);
Source

pub fn set_data_governance_type<T: Into<DataGovernanceType>>(self, v: T) -> Self

Sets the value of data_governance_type.

§Example
use google_cloud_bigquery_v2::model::routine::DataGovernanceType;
let x0 = Routine::new().set_data_governance_type(DataGovernanceType::DataMasking);
Source

pub fn set_python_options<T>(self, v: T) -> Self
where T: Into<PythonOptions>,

Sets the value of python_options.

§Example
use google_cloud_bigquery_v2::model::PythonOptions;
let x = Routine::new().set_python_options(PythonOptions::default()/* use setters */);
Source

pub fn set_or_clear_python_options<T>(self, v: Option<T>) -> Self
where T: Into<PythonOptions>,

Sets or clears the value of python_options.

§Example
use google_cloud_bigquery_v2::model::PythonOptions;
let x = Routine::new().set_or_clear_python_options(Some(PythonOptions::default()/* use setters */));
let x = Routine::new().set_or_clear_python_options(None::<PythonOptions>);
Source

pub fn set_external_runtime_options<T>(self, v: T) -> Self

Sets the value of external_runtime_options.

§Example
use google_cloud_bigquery_v2::model::ExternalRuntimeOptions;
let x = Routine::new().set_external_runtime_options(ExternalRuntimeOptions::default()/* use setters */);
Source

pub fn set_or_clear_external_runtime_options<T>(self, v: Option<T>) -> Self

Sets or clears the value of external_runtime_options.

§Example
use google_cloud_bigquery_v2::model::ExternalRuntimeOptions;
let x = Routine::new().set_or_clear_external_runtime_options(Some(ExternalRuntimeOptions::default()/* use setters */));
let x = Routine::new().set_or_clear_external_runtime_options(None::<ExternalRuntimeOptions>);
Source

pub fn set_build_status<T>(self, v: T) -> Self

Sets the value of build_status.

§Example
use google_cloud_bigquery_v2::model::RoutineBuildStatus;
let x = Routine::new().set_build_status(RoutineBuildStatus::default()/* use setters */);
Source

pub fn set_or_clear_build_status<T>(self, v: Option<T>) -> Self

Sets or clears the value of build_status.

§Example
use google_cloud_bigquery_v2::model::RoutineBuildStatus;
let x = Routine::new().set_or_clear_build_status(Some(RoutineBuildStatus::default()/* use setters */));
let x = Routine::new().set_or_clear_build_status(None::<RoutineBuildStatus>);

Trait Implementations§

Source§

impl Clone for Routine

Source§

fn clone(&self) -> Routine

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Routine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Routine

Source§

fn default() -> Routine

Returns the “default value” for a type. Read more
Source§

impl Message for Routine

Source§

fn typename() -> &'static str

The typename of this message.
Source§

impl PartialEq for Routine

Source§

fn eq(&self, other: &Routine) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Routine

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more