BigQuery API - Class Google::Cloud::Bigquery::StandardSql::DataType (v1.46.1)

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.

Returns
  • (Boolean) — true when ARRAY, 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.

Returns

#bignumeric?

def bignumeric?() -> Boolean

Checks if the #type_kind of the field is BIGNUMERIC.

Returns
  • (Boolean) — true when BIGNUMERIC, false otherwise.

#boolean?

def boolean?() -> Boolean

Checks if the #type_kind of the field is BOOL.

Returns
  • (Boolean) — true when BOOL, false otherwise.

#bytes?

def bytes?() -> Boolean

Checks if the #type_kind of the field is BYTES.

Returns
  • (Boolean) — true when BYTES, false otherwise.

#date?

def date?() -> Boolean

Checks if the #type_kind of the field is DATE.

Returns
  • (Boolean) — true when DATE, false otherwise.

#datetime?

def datetime?() -> Boolean

Checks if the #type_kind of the field is DATETIME.

Returns
  • (Boolean) — true when DATETIME, false otherwise.

#float?

def float?() -> Boolean

Checks if the #type_kind of the field is FLOAT64.

Returns
  • (Boolean) — true when FLOAT64, false otherwise.

#geography?

def geography?() -> Boolean

Checks if the #type_kind of the field is GEOGRAPHY.

Returns
  • (Boolean) — true when GEOGRAPHY, false otherwise.

#initialize

def initialize(type_kind, array_element_type, struct_type) -> DataType

Creates a new, immutable StandardSql::DataType object.

Overloads
def initialize(type_kind, array_element_type, struct_type) -> DataType
Creates a new, immutable StandardSql::DataType object.
Parameters
Returns
  • (DataType) — a new instance of DataType

#int?

def int?() -> Boolean

Checks if the #type_kind of the field is INT64.

Returns
  • (Boolean) — true when INT64, false otherwise.

#numeric?

def numeric?() -> Boolean

Checks if the #type_kind of the field is NUMERIC.

Returns
  • (Boolean) — true when NUMERIC, false otherwise.

#string?

def string?() -> Boolean

Checks if the #type_kind of the field is STRING.

Returns
  • (Boolean) — true when STRING, false otherwise.

#struct?

def struct?() -> Boolean

Checks if the #type_kind of the field is STRUCT.

Returns
  • (Boolean) — true when STRUCT, false otherwise.

#struct_type

def struct_type() -> StructType, nil

The fields of the struct, in order, if #type_kind is STRUCT. See #struct?. Optional.

Returns

#time?

def time?() -> Boolean

Checks if the #type_kind of the field is TIME.

Returns
  • (Boolean) — true when TIME, false otherwise.

#timestamp?

def timestamp?() -> Boolean

Checks if the #type_kind of the field is TIMESTAMP.

Returns
  • (Boolean) — true when TIMESTAMP, 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).

Returns
  • (String) — The upper case type.