Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::Argument.
Argument
Input/output argument of a function or a stored procedure. See Routine.
Inherits
- Object
Example
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.body = "(SELECT SUM(IF(elem.name = \"foo\",elem.val,null)) FROM UNNEST(arr) AS elem)" r.arguments = [ Google::Cloud::Bigquery::Argument.new( name: "arr", argument_kind: "FIXED_TYPE", data_type: Google::Cloud::Bigquery::StandardSql::DataType.new( type_kind: "ARRAY", array_element_type: Google::Cloud::Bigquery::StandardSql::DataType.new( type_kind: "STRUCT", struct_type: Google::Cloud::Bigquery::StandardSql::StructType.new( fields: [ Google::Cloud::Bigquery::StandardSql::Field.new( name: "name", type: Google::Cloud::Bigquery::StandardSql::DataType.new(type_kind: "STRING") ), Google::Cloud::Bigquery::StandardSql::Field.new( name: "val", type: Google::Cloud::Bigquery::StandardSql::DataType.new(type_kind: "INT64") ) ] ) ) ) ) ] end
Methods
#any_type?
def any_type?() -> Boolean
Checks if the value of #argument_kind is ANY_TYPE
. The default is false
.
-
(Boolean) —
true
whenANY_TYPE
,false
otherwise.
#argument_kind
def argument_kind() -> String
The kind of argument. Optional. Defaults to FIXED_TYPE
.
FIXED_TYPE
- The argument is a variable with fully specified type, which can be a struct or an array, but not a table.ANY_TYPE
- The argument is any type, including struct or array, but not a table.
To be added: FIXED_TABLE
, ANY_TABLE
.
- (String) — The upper case kind of argument.
#data_type
def data_type() -> StandardSql::DataType
The data type of the argument. Required unless #argument_kind is ANY_TYPE
.
- (StandardSql::DataType) — The data type.
#fixed_type?
def fixed_type?() -> Boolean
Checks if the value of #argument_kind is FIXED_TYPE
. The default is true
.
-
(Boolean) —
true
whenFIXED_TYPE
,false
otherwise.
#in?
def in?() -> Boolean
Checks if the value of #mode is IN
. Can be set for procedures only. The default is false
.
-
(Boolean) —
true
whenIN
,false
otherwise.
#initialize
def initialize(data_type, kind, mode, name) -> Argument
Creates a new, immutable Argument object.
def initialize(data_type, kind, mode, name) -> Argument
-
data_type (StandardSql::DataType, String) — The data type of the argument. Required unless
#argument_kind is
ANY_TYPE
. -
argument_kind (String) — The kind of argument. Optional. Defaults to
FIXED_TYPE
.FIXED_TYPE
- The argument is a variable with fully specified type, which can be a struct or an array, but not a table.ANY_TYPE
- The argument is any type, including struct or array, but not a table.
To be added:
FIXED_TABLE
,ANY_TABLE
. -
mode (String) —
Specifies whether the argument is input or output. Optional. Can be set for procedures only.
- IN - The argument is input-only.
- OUT - The argument is output-only.
- INOUT - The argument is both an input and an output.
- name (String) — The name of the argument. Optional. Can be absent for a function return argument.
- (Argument) — a new instance of Argument
#inout?
def inout?() -> Boolean
Checks if the value of #mode is INOUT
. Can be set for procedures only. The default is false
.
-
(Boolean) —
true
whenINOUT
,false
otherwise.
#mode
def mode() -> String
Specifies whether the argument is input or output. Optional. Can be set for procedures only.
- IN - The argument is input-only.
- OUT - The argument is output-only.
- INOUT - The argument is both an input and an output.
- (String) — The upper case input/output mode of the argument.
#name
def name() -> String
The name of the argument. Optional. Can be absent for a function return argument.
- (String) — The name of the argument.
#out?
def out?() -> Boolean
Checks if the value of #mode is OUT
. Can be set for procedures only. The default is false
.
-
(Boolean) —
true
whenOUT
,false
otherwise.