pub struct Routine {Show 18 fields
pub etag: String,
pub routine_reference: Option<RoutineReference>,
pub routine_type: i32,
pub creation_time: i64,
pub last_modified_time: i64,
pub language: i32,
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: i32,
pub security_mode: i32,
pub strict_mode: Option<bool>,
pub remote_function_options: Option<RemoteFunctionOptions>,
pub spark_options: Option<SparkOptions>,
pub data_governance_type: i32,
}
Expand description
A user-defined function or a stored procedure.
Fields§
§etag: String
Output only. A hash of this resource.
routine_reference: Option<RoutineReference>
Required. Reference describing the ID of this routine.
routine_type: i32
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: i32
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.
description: String
Optional. The description of the routine, if defined.
determinism_level: i32
Optional. The determinism level of the JavaScript UDF, if defined.
security_mode: i32
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<bool>
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: i32
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.
Implementations§
source§impl Routine
impl Routine
sourcepub fn routine_type(&self) -> RoutineType
pub fn routine_type(&self) -> RoutineType
Returns the enum value of routine_type
, or the default if the field is set to an invalid enum value.
sourcepub fn set_routine_type(&mut self, value: RoutineType)
pub fn set_routine_type(&mut self, value: RoutineType)
Sets routine_type
to the provided enum value.
sourcepub fn language(&self) -> Language
pub fn language(&self) -> Language
Returns the enum value of language
, or the default if the field is set to an invalid enum value.
sourcepub fn set_language(&mut self, value: Language)
pub fn set_language(&mut self, value: Language)
Sets language
to the provided enum value.
sourcepub fn determinism_level(&self) -> DeterminismLevel
pub fn determinism_level(&self) -> DeterminismLevel
Returns the enum value of determinism_level
, or the default if the field is set to an invalid enum value.
sourcepub fn set_determinism_level(&mut self, value: DeterminismLevel)
pub fn set_determinism_level(&mut self, value: DeterminismLevel)
Sets determinism_level
to the provided enum value.
sourcepub fn data_governance_type(&self) -> DataGovernanceType
pub fn data_governance_type(&self) -> DataGovernanceType
Returns the enum value of data_governance_type
, or the default if the field is set to an invalid enum value.
sourcepub fn set_data_governance_type(&mut self, value: DataGovernanceType)
pub fn set_data_governance_type(&mut self, value: DataGovernanceType)
Sets data_governance_type
to the provided enum value.
sourcepub fn security_mode(&self) -> SecurityMode
pub fn security_mode(&self) -> SecurityMode
Returns the enum value of security_mode
, or the default if the field is set to an invalid enum value.
sourcepub fn set_security_mode(&mut self, value: SecurityMode)
pub fn set_security_mode(&mut self, value: SecurityMode)
Sets security_mode
to the provided enum value.
Trait Implementations§
source§impl Message for Routine
impl Message for Routine
source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
. Read moresource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
.source§impl PartialEq for Routine
impl PartialEq for Routine
impl StructuralPartialEq for Routine
Auto Trait Implementations§
impl Freeze for Routine
impl RefUnwindSafe for Routine
impl Send for Routine
impl Sync for Routine
impl Unpin for Routine
impl UnwindSafe for Routine
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request