Connect with us

Tech

BigQuery API – Class Google::Cloud::Bigquery::Schema (v1.49.1) | Ruby Client Library | Google Cloud

BigQuery API – Class Google::Cloud::Bigquery::Schema (v1.49.1) | Ruby Client Library | Google Cloud

 


Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::Schema.

Table Schema

A builder for BigQuery table schema, passed to the block argument of Dataset#create_table and Table#schema. Supports nested and repeated fields via nested blocks.

Example require “google/cloud/bigquery” bigquery = Google::Cloud::Bigquery.new dataset = bigquery.dataset “my_dataset” table = dataset.create_table “my_table” table.schema do |schema| schema.string “first_name”, mode: :required schema.record “cities_lived”, mode: :repeated do |cities_lived| cities_lived.string “place”, mode: :required cities_lived.integer “number_of_years”, mode: :required end end Method .dump def self.dump(schema, destination) -> Schema

Write the schema to a file as JSON.

The JSON schema file is the same as for the bq CLI.

Parameters schema (Schema) Google::Cloud::Bigquery::Schema. destination (IO, String) IO to write the schema to, or a string containing the filename to write to. Returns (Schema) Schema that allows commands to be chained. Example require “google/cloud/bigquery” bigquery = Google::Cloud::Bigquery.new dataset = bigquery.dataset “my_dataset” table = dataset.table “my_table” schema = Google::Cloud::Bigquery::Schema.dump( table.schema, “schema.json” ) .load def self.load(source) -> Schema

Loads a schema from a JSON file.

The JSON schema file is the same as in the bq CLI and consists of an array of JSON objects containing the following:

name: Column name type: Column data type description: (Optional) Column description mode: (Optional) Column mode (if not specified, mode defaults to NULLABLE) fields: If type is RECORD, an array of objects defining child fields with these properties Parameter source (IO, string, array)) An IO containing a JSON schema, a string containing a JSON schema, or an array of hashes containing the schema details. Example require “google/cloud/bigquery” schema = Google::Cloud::Bigquery::Schema.load( File.read(“schema.json”) ) #bignumeric def bignumeric(name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil, default_value_expression: nil)

Adds a bignumeric numeric field to a schema. BIGNUMERIC is a decimal type with a fixed precision and scale. Precision is the number of digits the number contains. Scale is how many of these digits appear after the decimal point. Supported:

Precision: 76.76 (77th digit is partial) Scale: 38 Minimum: -5.7896044618658097711785492504343953926634992332820282019728792003956564819968E+38 Maximum: 5.7896044618658097711785492504343953926634992332820282019728792003956564819967E+38

This type is suitable for financial calculations because it can accurately represent decimals.

#boolean def boolean(name, description: nil, mode: :nullable, policy tag: nil, default value expression: nil)

Add a boolean field to the schema.

#bytes def bytes(name, description: nil, mode: :nullable, policytag: nil, maxlength: nil, defaultvalueexpression: nil)

Add a byte field to the schema.

#date def date(name, description: nil, mode: :nullable, policy tag: nil, default value expression: nil)

Add a date field to the schema.

#datetime def datetime(name, description: nil, mode: :nullable, policy tag: nil, default value expression: nil)

Add a datetime field to the schema.

#dump def dump(destination) -> schema

Write the schema to a file as JSON.

The JSON schema file is the same as for the bq CLI.

Parameters destination (IO, String) IO to write the schema to, or a string containing the filename to write to. Returns (Schema) Schema that allows commands to be chained. Example require “google/cloud/bigquery” bigquery = Google::Cloud::Bigquery.new dataset = bigquery.dataset “my_dataset” table = dataset.table “my_table” table.schema.dump “schema.json” #empty?

The field is not defined in the schema.

Returns true if the field does not exist, false otherwise (Boolean).

Gets a field by name.

Example require “google/cloud/bigquery” bigquery = Google::Cloud::Bigquery.new dataset = bigquery.dataset “my_dataset” table = dataset.table “my_table” field = table.schema.field “name” field.required? #=> true #fields def fields() -> Array

A field in the table schema.

Returns (array) An array of field objects. Example: require “google/cloud/bigquery” bigquery = Google::Cloud::Bigquery.new dataset = bigquery.dataset “my_dataset” table = dataset.table “my_table” schema = table.schema schema.fields.each do |field| puts field.name end #float def float(name, description: nil, mode: :nullable, policy_tags: nil, default_value_expression: nil)

Add a floating point field to the schema.

#geography def geography(name, description: nil, mode: :nullable, policy tag: nil, default value expression: nil)

Add a geography field to the schema.

def headers() -> array

Displays the name of the field as a symbol.

Returns (array) An array of column names. Example require “google/cloud/bigquery” bigquery = Google::Cloud::Bigquery.new dataset = bigquery.dataset “my_dataset” table = dataset.create_table “my_table” schema = table.schema schema.headers.each do |header| puts header end #integer def integer(name, description: nil, mode: :nullable, policy_tags: nil, default_value_expression: nil)

Add an integer field to the schema.

#json def json(name, description: nil, mode: :nullable, policy tag: nil, default value expression: nil)

Add a JSON field to the schema.

#load def load(source) -> schema

Loads a schema from a JSON file.

The JSON schema file is the same as in the bq CLI and consists of an array of JSON objects containing the following:

name: Column name type: Column data type description: (Optional) Column description mode: (Optional) Column mode (if not specified, mode defaults to NULLABLE) fields: If type is RECORD, an array of objects defining child fields with these properties Parameter source (IO, string, array)) IO containing a JSON schema, a string containing a JSON schema, or an array of hashes containing the schema details. Returns (schema) Returns the schema so that commands can be chained. Example require “google/cloud/bigquery” bigquery = Google::Cloud::Bigquery.new dataset = bigquery.dataset “my_dataset” table = dataset.table “my_table” do |t| t.schema.load File.read(“path/to/schema.json”) end #numeric def numeric(name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil, default_value_expression: nil)

Adds a numeric field to the schema. NUMERIC is a decimal type with a fixed precision and scale. Precision is the number of digits a number contains. Scale is how many of these digits appear after the decimal point. Supported:

Precision: 38 Scale: 9 Minimum: -9.9999999999999999999999999999999999999999999E+28 Maximum: 9.9999999999999999999999999999999999999999E+28

This type is suitable for financial calculations because it can accurately represent decimals.

#param_types def param_types() -> hash

The type of field, using the same format as the optional query parameter type.

Returns (hash) A hash with column names as keys and types as values. Example require “google/cloud/bigquery” bigquery = Google::Cloud::Bigquery.new dataset = bigquery.dataset “my_dataset” table = dataset.create_table “my_table” schema = table.schema schema.param_types #record def record(name, description: nil, mode: nil, default_value_expression: nil) { |field| … } Generate (field) A block to set the schema of a nested record Parameter to generate field (Field) An object that accepts a nested schema Example require “google/cloud/bigquery” bigquery = Google::Cloud::Bigquery.new dataset = bigquery.dataset “my_dataset” table = dataset.create_table “my_table” table.schema do |schema| schema.string “first_name”, mode: :required schema.record “cities_lived”, mode: :repeated do |cities_lived| cities_lived.string “place”, mode: :required cities_lived.integer “number_of_years”, mode: :required end end #string def string(name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil, default_value_expression: nil)

Add a string field to the schema.

#time def time(name, description: nil, mode: :nullable, policy tag: nil, default value expression: nil)

Add a time field to the schema.

#timestamp def timestamp(name, description: nil, mode: :nullable, policy tag: nil, default value expression: nil)

Add a timestamp field to the schema.

Sources

1/ https://Google.com/

2/ https://cloud.google.com/ruby/docs/reference/google-cloud-bigquery/1.49.1/Google-Cloud-Bigquery-Schema

The mention sources can contact us to remove/changing this article

What Are The Main Benefits Of Comparing Car Insurance Quotes Online

LOS ANGELES, CA / ACCESSWIRE / June 24, 2020, / Compare-autoinsurance.Org has launched a new blog post that presents the main benefits of comparing multiple car insurance quotes. For more info and free online quotes, please visit https://compare-autoinsurance.Org/the-advantages-of-comparing-prices-with-car-insurance-quotes-online/ The modern society has numerous technological advantages. One important advantage is the speed at which information is sent and received. With the help of the internet, the shopping habits of many persons have drastically changed. The car insurance industry hasn't remained untouched by these changes. On the internet, drivers can compare insurance prices and find out which sellers have the best offers. View photos The advantages of comparing online car insurance quotes are the following: Online quotes can be obtained from anywhere and at any time. Unlike physical insurance agencies, websites don't have a specific schedule and they are available at any time. Drivers that have busy working schedules, can compare quotes from anywhere and at any time, even at midnight. Multiple choices. Almost all insurance providers, no matter if they are well-known brands or just local insurers, have an online presence. Online quotes will allow policyholders the chance to discover multiple insurance companies and check their prices. Drivers are no longer required to get quotes from just a few known insurance companies. Also, local and regional insurers can provide lower insurance rates for the same services. Accurate insurance estimates. Online quotes can only be accurate if the customers provide accurate and real info about their car models and driving history. Lying about past driving incidents can make the price estimates to be lower, but when dealing with an insurance company lying to them is useless. Usually, insurance companies will do research about a potential customer before granting him coverage. Online quotes can be sorted easily. Although drivers are recommended to not choose a policy just based on its price, drivers can easily sort quotes by insurance price. Using brokerage websites will allow drivers to get quotes from multiple insurers, thus making the comparison faster and easier. For additional info, money-saving tips, and free car insurance quotes, visit https://compare-autoinsurance.Org/ Compare-autoinsurance.Org is an online provider of life, home, health, and auto insurance quotes. This website is unique because it does not simply stick to one kind of insurance provider, but brings the clients the best deals from many different online insurance carriers. In this way, clients have access to offers from multiple carriers all in one place: this website. On this site, customers have access to quotes for insurance plans from various agencies, such as local or nationwide agencies, brand names insurance companies, etc. "Online quotes can easily help drivers obtain better car insurance deals. All they have to do is to complete an online form with accurate and real info, then compare prices", said Russell Rabichev, Marketing Director of Internet Marketing Company. CONTACT: Company Name: Internet Marketing CompanyPerson for contact Name: Gurgu CPhone Number: (818) 359-3898Email: [email protected]: https://compare-autoinsurance.Org/ SOURCE: Compare-autoinsurance.Org View source version on accesswire.Com:https://www.Accesswire.Com/595055/What-Are-The-Main-Benefits-Of-Comparing-Car-Insurance-Quotes-Online View photos

ExBUlletin

to request, modification Contact us at Here or [email protected]