Send feedback
BigQuery API - Class Google::Cloud::Bigquery::StandardSql::StructType (v1.58.0)
Stay organized with collections
Save and categorize content based on your preferences.
Version latestkeyboard_arrow_down
Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::StandardSql::StructType.
The fields of a STRUCT
type. See DataType#struct_type . See Routine and Argument .
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
#fields
def fields () - > Array<Field>
The fields of the struct.
Returns
(Array<Field>) — A frozen array of fields.
#initialize
def initialize ( fields ) - > StructType
Creates a new, immutable StandardSql::StructType object.
Overloads
def initialize ( fields ) - > StructType
Creates a new, immutable StandardSql::StructType object.
Parameter
fields (Array<Field>) — The fields of the struct. Required.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-09 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-09 UTC."],[],[],null,["# BigQuery API - Class Google::Cloud::Bigquery::StandardSql::StructType (v1.56.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.56.0 (latest)](/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.55.0](/ruby/docs/reference/google-cloud-bigquery/1.55.0/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.54.0](/ruby/docs/reference/google-cloud-bigquery/1.54.0/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.53.0](/ruby/docs/reference/google-cloud-bigquery/1.53.0/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.52.1](/ruby/docs/reference/google-cloud-bigquery/1.52.1/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.51.1](/ruby/docs/reference/google-cloud-bigquery/1.51.1/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.50.0](/ruby/docs/reference/google-cloud-bigquery/1.50.0/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.49.1](/ruby/docs/reference/google-cloud-bigquery/1.49.1/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.48.1](/ruby/docs/reference/google-cloud-bigquery/1.48.1/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.47.0](/ruby/docs/reference/google-cloud-bigquery/1.47.0/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.46.1](/ruby/docs/reference/google-cloud-bigquery/1.46.1/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.45.0](/ruby/docs/reference/google-cloud-bigquery/1.45.0/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.44.2](/ruby/docs/reference/google-cloud-bigquery/1.44.2/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.43.1](/ruby/docs/reference/google-cloud-bigquery/1.43.1/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.42.0](/ruby/docs/reference/google-cloud-bigquery/1.42.0/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.41.0](/ruby/docs/reference/google-cloud-bigquery/1.41.0/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.40.0](/ruby/docs/reference/google-cloud-bigquery/1.40.0/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.39.0](/ruby/docs/reference/google-cloud-bigquery/1.39.0/Google-Cloud-Bigquery-StandardSql-StructType)\n- [1.38.1](/ruby/docs/reference/google-cloud-bigquery/1.38.1/Google-Cloud-Bigquery-StandardSql-StructType) \nReference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::StandardSql::StructType.\n\nThe fields of a `STRUCT` type. See [DataType#struct_type](/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-StandardSql-DataType#Google__Cloud__Bigquery__StandardSql__DataType_struct_type_instance_ \"Google::Cloud::Bigquery::StandardSql::DataType#struct_type (method)\"). See [Routine](/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Routine \"Google::Cloud::Bigquery::Routine (class)\") and [Argument](/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-Argument \"Google::Cloud::Bigquery::Argument (class)\"). \n\nInherits\n--------\n\n- Object\n\nExample\n-------\n\n```ruby\nrequire \"google/cloud/bigquery\"\n\nbigquery = Google::Cloud::Bigquery.new\ndataset = bigquery.dataset \"my_dataset\"\nroutine = dataset.create_routine \"my_routine\" do |r|\n r.routine_type = \"SCALAR_FUNCTION\"\n r.language = :SQL\n r.body = \"(SELECT SUM(IF(elem.name = \\\"foo\\\",elem.val,null)) FROM UNNEST(arr) AS elem)\"\n r.arguments = [\n Google::Cloud::Bigquery::Argument.new(\n name: \"arr\",\n argument_kind: \"FIXED_TYPE\",\n data_type: Google::Cloud::Bigquery::StandardSql::DataType.new(\n type_kind: \"ARRAY\",\n array_element_type: Google::Cloud::Bigquery::StandardSql::DataType.new(\n type_kind: \"STRUCT\",\n struct_type: Google::Cloud::Bigquery::StandardSql::StructType.new(\n fields: [\n Google::Cloud::Bigquery::StandardSql::Field.new(\n name: \"name\",\n type: Google::Cloud::Bigquery::StandardSql::DataType.new(type_kind: \"STRING\")\n ),\n Google::Cloud::Bigquery::StandardSql::Field.new(\n name: \"val\",\n type: Google::Cloud::Bigquery::StandardSql::DataType.new(type_kind: \"INT64\")\n )\n ]\n )\n )\n )\n )\n ]\nend\n```\n\nMethods\n-------\n\n### #fields\n\n def fields() -\u003e Array\u003cField\u003e\n\nThe fields of the struct. \n**Returns**\n\n- (Array\\\u003cField\\\u003e) --- A frozen array of fields.\n\n### #initialize\n\n def initialize(fields) -\u003e StructType\n\nCreates a new, immutable StandardSql::StructType object. \n**Overloads** \n\n def initialize(fields) -\u003e StructType\n\nCreates a new, immutable StandardSql::StructType object. \n**Parameter**\n\n- **fields** (Array\\\u003cField\\\u003e) --- The fields of the struct. Required. \n**Returns**\n\n- ([StructType](./Google-Cloud-Bigquery-StandardSql-StructType)) --- a new instance of StructType"]]