class Google::Cloud::Bigquery::StandardSql::StructType
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 fields of a ‘STRUCT` type. See {DataType#struct_type}. See {Routine} and {Argument}.
#
def self.from_gapi gapi
- Private: - New StandardSql::StructType from a Google::Apis::BigqueryV2::StandardSqlStructType object.
def self.from_gapi gapi new.tap do |f| f.instance_variable_set :@gapi, gapi end end
def fields
-
(Array- A frozen array of fields.)
def fields Array(@gapi.fields).map do |field_gapi| Field.from_gapi field_gapi end.freeze end
def initialize **kwargs
-
fields(Array) -- The fields of the struct. Required.
Overloads:
-
initialize(fields)
def initialize **kwargs # Convert each field client object to gapi object, if fields given (self.from_gapi does not pass kwargs) kwargs[:fields] = kwargs[:fields]&.map(&:to_gapi) if kwargs[:fields] @gapi = Google::Apis::BigqueryV2::StandardSqlStructType.new(**kwargs) end
def to_gapi
- Private: - New Google::Apis::BigqueryV2::StandardSqlStructType object.
def to_gapi @gapi end