class Google::Cloud::Bigquery::StandardSql::DataType
@see cloud.google.com/bigquery/docs/reference/standard-sql/data-types Standard SQL Data Types
end
]
)
)
)
)
]
)
type: Google::Cloud::Bigquery::StandardSql::DataType.new(type_kind: “INT64”)
name: “val”,
Google::Cloud::Bigquery::StandardSql::Field.new(
),
type: Google::Cloud::Bigquery::StandardSql::DataType.new(type_kind: “STRING”)
name: “name”,
Google::Cloud::Bigquery::StandardSql::Field.new(
fields: [
struct_type: Google::Cloud::Bigquery::StandardSql::StructType.new(
type_kind: “STRUCT”,
array_element_type: Google::Cloud::Bigquery::StandardSql::DataType.new(
type_kind: “ARRAY”,
data_type: Google::Cloud::Bigquery::StandardSql::DataType.new(
argument_kind: “FIXED_TYPE”,
name: “arr”,
Google::Cloud::Bigquery::Argument.new(
r.arguments = [
r.body = “(SELECT SUM(IF(elem.name = "foo",elem.val,null)) FROM UNNEST(arr) AS elem)”
r.language = :SQL
r.routine_type = “SCALAR_FUNCTION”
routine = dataset.create_routine “my_routine” do |r|
dataset = bigquery.dataset “my_dataset”
bigquery = Google::Cloud::Bigquery.new
require “google/cloud/bigquery”
@example
The type of a variable, e.g., a function argument. See {Routine} and {Argument}.
#
def self.from_gapi gapi
- Private: - New StandardSql::DataType from a Google::Apis::BigqueryV2::StandardSqlDataType object.
def self.from_gapi gapi new.tap do |f| f.instance_variable_set :@gapi, gapi end end
def self.gapi_from_string_or_data_type data_type
- Private: - New Google::Apis::BigqueryV2::StandardSqlDataType from a String or StandardSql::DataType object.
def self.gapi_from_string_or_data_type data_type return if data_type.nil? case data_type when StandardSql::DataType data_type.to_gapi when Hash data_type when String, Symbol Google::Apis::BigqueryV2::StandardSqlDataType.new type_kind: data_type.to_s.upcase else raise ArgumentError, "Unable to convert #{data_type} to Google::Apis::BigqueryV2::StandardSqlDataType" end end
def array?
-
(Boolean)- `true` when `ARRAY`, `false` otherwise.
def array? type_kind == "ARRAY".freeze end
def array_element_type
-
(DataType, nil)-
def array_element_type return if @gapi.array_element_type.nil? DataType.from_gapi @gapi.array_element_type end
def bignumeric?
-
(Boolean)- `true` when `BIGNUMERIC`, `false` otherwise.
def bignumeric? type_kind == "BIGNUMERIC".freeze end
def boolean?
-
(Boolean)- `true` when `BOOL`, `false` otherwise.
def boolean? type_kind == "BOOL".freeze end
def bytes?
-
(Boolean)- `true` when `BYTES`, `false` otherwise.
def bytes? type_kind == "BYTES".freeze end
def date?
-
(Boolean)- `true` when `DATE`, `false` otherwise.
def date? type_kind == "DATE".freeze end
def datetime?
-
(Boolean)- `true` when `DATETIME`, `false` otherwise.
def datetime? type_kind == "DATETIME".freeze end
def float?
-
(Boolean)- `true` when `FLOAT64`, `false` otherwise.
def float? type_kind == "FLOAT64".freeze end
def geography?
-
(Boolean)- `true` when `GEOGRAPHY`, `false` otherwise.
def geography? type_kind == "GEOGRAPHY".freeze end
def initialize **kwargs
-
struct_type(StructType) -- The fields of the struct, in order, if {#type_kind} is `STRUCT`. See -
array_element_type(DataType, String) -- The type of the array's elements, if {#type_kind} is `ARRAY`. -
type_kind(String) -- The top level type of this field. Required. Can be [any standard SQL data
Overloads:
-
initialize(type_kind, array_element_type, struct_type)
def initialize **kwargs # Convert client object kwargs to a gapi object if kwargs[:array_element_type] kwargs[:array_element_type] = self.class.gapi_from_string_or_data_type kwargs[:array_element_type] end kwargs[:struct_type] = kwargs[:struct_type].to_gapi if kwargs[:struct_type] @gapi = Google::Apis::BigqueryV2::StandardSqlDataType.new(**kwargs) end
def int?
-
(Boolean)- `true` when `INT64`, `false` otherwise.
def int? type_kind == "INT64".freeze end
def numeric?
-
(Boolean)- `true` when `NUMERIC`, `false` otherwise.
def numeric? type_kind == "NUMERIC".freeze end
def string?
-
(Boolean)- `true` when `STRING`, `false` otherwise.
def string? type_kind == "STRING".freeze end
def struct?
-
(Boolean)- `true` when `STRUCT`, `false` otherwise.
def struct? type_kind == "STRUCT".freeze end
def struct_type
-
(StructType, nil)-
def struct_type return if @gapi.struct_type.nil? StructType.from_gapi @gapi.struct_type end
def time?
-
(Boolean)- `true` when `TIME`, `false` otherwise.
def time? type_kind == "TIME".freeze end
def timestamp?
-
(Boolean)- `true` when `TIMESTAMP`, `false` otherwise.
def timestamp? type_kind == "TIMESTAMP".freeze end
def to_gapi
- Private: - New Google::Apis::BigqueryV2::StandardSqlDataType object.
def to_gapi @gapi end
def type_kind
-
(String)- The upper case type.
Other tags:
- See: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types - Standard SQL Data Types
def type_kind @gapi.type_kind end