Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::StandardSql::DataType.
The type of a variable, e.g., a function argument. See Routine and Argument.
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
#array?
def array?() -> Boolean
Checks if the #type_kind of the field is ARRAY
.
-
(Boolean) —
true
whenARRAY
,false
otherwise.
#array_element_type
def array_element_type() -> DataType, nil
The type of the array's elements, if #type_kind is ARRAY
. See #array?. Optional.
- (DataType, nil)
#bignumeric?
def bignumeric?() -> Boolean
Checks if the #type_kind of the field is BIGNUMERIC
.
-
(Boolean) —
true
whenBIGNUMERIC
,false
otherwise.
#boolean?
def boolean?() -> Boolean
Checks if the #type_kind of the field is BOOL
.
-
(Boolean) —
true
whenBOOL
,false
otherwise.
#bytes?
def bytes?() -> Boolean
Checks if the #type_kind of the field is BYTES
.
-
(Boolean) —
true
whenBYTES
,false
otherwise.
#date?
def date?() -> Boolean
Checks if the #type_kind of the field is DATE
.
-
(Boolean) —
true
whenDATE
,false
otherwise.
#datetime?
def datetime?() -> Boolean
Checks if the #type_kind of the field is DATETIME
.
-
(Boolean) —
true
whenDATETIME
,false
otherwise.
#float?
def float?() -> Boolean
Checks if the #type_kind of the field is FLOAT64
.
-
(Boolean) —
true
whenFLOAT64
,false
otherwise.
#geography?
def geography?() -> Boolean
Checks if the #type_kind of the field is GEOGRAPHY
.
-
(Boolean) —
true
whenGEOGRAPHY
,false
otherwise.
#initialize
def initialize(type_kind, array_element_type, struct_type) -> DataType
Creates a new, immutable StandardSql::DataType object.
def initialize(type_kind, array_element_type, struct_type) -> DataType
-
type_kind (String) — The top level type of this field. Required. Can be any standard SQL data
type (e.g.,
INT64
,DATE
,ARRAY
). -
array_element_type (DataType, String) — The type of the array's elements, if #type_kind is
ARRAY
. See #array?. Optional. -
struct_type (StructType) — The fields of the struct, in order, if #type_kind is
STRUCT
. See #struct?. Optional.
- (DataType) — a new instance of DataType
#int?
def int?() -> Boolean
Checks if the #type_kind of the field is INT64
.
-
(Boolean) —
true
whenINT64
,false
otherwise.
#numeric?
def numeric?() -> Boolean
Checks if the #type_kind of the field is NUMERIC
.
-
(Boolean) —
true
whenNUMERIC
,false
otherwise.
#string?
def string?() -> Boolean
Checks if the #type_kind of the field is STRING
.
-
(Boolean) —
true
whenSTRING
,false
otherwise.
#struct?
def struct?() -> Boolean
Checks if the #type_kind of the field is STRUCT
.
-
(Boolean) —
true
whenSTRUCT
,false
otherwise.
#struct_type
def struct_type() -> StructType, nil
The fields of the struct, in order, if #type_kind is STRUCT
. See #struct?. Optional.
- (StructType, nil)
#time?
def time?() -> Boolean
Checks if the #type_kind of the field is TIME
.
-
(Boolean) —
true
whenTIME
,false
otherwise.
#timestamp?
def timestamp?() -> Boolean
Checks if the #type_kind of the field is TIMESTAMP
.
-
(Boolean) —
true
whenTIMESTAMP
,false
otherwise.
#type_kind
def type_kind() -> String
The top level type of this field. Required. Can be any standard SQL data type (e.g., INT64
, DATE
,
ARRAY
).
- (String) — The upper case type.