BigQuery API - Class Google::Cloud::Bigquery::External::BigtableSource::ColumnFamily (v1.44.1)

Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::External::BigtableSource::ColumnFamily.

BigtableSource::ColumnFamily

A Bigtable column family used to expose in the table schema along with its types and columns.

Inherits

  • Object

Example

require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.rowkey_as_string = true
  bt.add_family "user" do |u|
    u.add_string "name"
    u.add_string "email"
    u.add_integer "age"
    u.add_boolean "active"
  end
end

data = bigquery.query "SELECT * FROM my_ext_table",
                      external: { my_ext_table: bigtable_table }

# Iterate over the first page of results
data.each do |row|
  puts row[:name]
end
# Retrieve the next page of results
data = data.next if data.next?

Methods

#add_boolean

def add_boolean(qualifier, as: nil) { |column| ... } -> Array<BigtableSource::Column>

Add a column to the column family to expose in the table schema that is specified as the BOOLEAN type.

Parameters
Yields
  • (column) — a block for setting the column
Yield Parameter
Returns
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.rowkey_as_string = true
  bt.add_family "user" do |u|
    u.add_boolean "active"
  end
end

#add_bytes

def add_bytes(qualifier, as: nil) { |column| ... } -> Array<BigtableSource::Column>

Add a column to the column family to expose in the table schema that is specified as the BYTES type.

Parameters
Yields
  • (column) — a block for setting the column
Yield Parameter
Returns
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.rowkey_as_string = true
  bt.add_family "user" do |u|
    u.add_bytes "avatar"
  end
end

#add_column

def add_column(qualifier, as: nil, type: nil) { |column| ... } -> Array<BigtableSource::Column>

Add a column to the column family to expose in the table schema along with its types.

  • BYTES
  • STRING
  • INTEGER
  • FLOAT
  • BOOLEAN
Parameters
Yields
  • (column) — a block for setting the column
Yield Parameter
Returns
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.rowkey_as_string = true
  bt.add_family "user" do |u|
    u.add_column "name", type: "STRING"
  end
end

#add_float

def add_float(qualifier, as: nil) { |column| ... } -> Array<BigtableSource::Column>

Add a column to the column family to expose in the table schema that is specified as the FLOAT type.

Parameters
Yields
  • (column) — a block for setting the column
Yield Parameter
Returns
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.rowkey_as_string = true
  bt.add_family "user" do |u|
    u.add_float "score"
  end
end

#add_integer

def add_integer(qualifier, as: nil) { |column| ... } -> Array<BigtableSource::Column>

Add a column to the column family to expose in the table schema that is specified as the INTEGER type.

Parameters
Yields
  • (column) — a block for setting the column
Yield Parameter
Returns
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.rowkey_as_string = true
  bt.add_family "user" do |u|
    u.add_integer "age"
  end
end

#add_string

def add_string(qualifier, as: nil) { |column| ... } -> Array<BigtableSource::Column>

Add a column to the column family to expose in the table schema that is specified as the STRING type.

Parameters
Yields
  • (column) — a block for setting the column
Yield Parameter
Returns
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.rowkey_as_string = true
  bt.add_family "user" do |u|
    u.add_string "name"
  end
end

#columns

def columns() -> Array<BigtableSource::Column>

Lists of columns that should be exposed as individual fields.

Returns
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.rowkey_as_string = true
  bt.add_family "user" do |u|
    u.add_string "name"
    u.add_string "email"
    u.add_integer "age"
    u.add_boolean "active"
  end
end

bigtable_table.families[0].columns.count #=> 4

#encoding

def encoding() -> String

The encoding of the values when the type is not STRING.

Returns
  • (String)
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.add_family "user" do |u|
    u.encoding = "UTF-8"
  end
end

bigtable_table.families[0].encoding #=> "UTF-8"

#encoding=

def encoding=(new_encoding)

Set the encoding of the values when the type is not STRING. Acceptable encoding values are:

  • TEXT - indicates values are alphanumeric text strings.
  • BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions. This can be overridden on a column.
Parameter
  • new_encoding (String) — New encoding value
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.add_family "user" do |u|
    u.encoding = "UTF-8"
  end
end

bigtable_table.families[0].encoding #=> "UTF-8"

#family_id

def family_id() -> String

Identifier of the column family.

Returns
  • (String)
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.add_family "user"
end

bigtable_table.families[0].family_id #=> "user"

#family_id=

def family_id=(new_family_id)

Set the identifier of the column family.

Parameter
  • new_family_id (String) — New family_id value
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.add_family "user"
end

bigtable_table.families[0].family_id #=> "user"
bigtable_table.families[0].family_id = "User"
bigtable_table.families[0].family_id #=> "User"

#latest

def latest() -> Boolean

Whether only the latest version of value are exposed for all columns in this column family.

Returns
  • (Boolean)
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.add_family "user" do |u|
    u.latest = true
  end
end

bigtable_table.families[0].latest #=> true

#latest=

def latest=(new_latest)

Set whether only the latest version of value are exposed for all columns in this column family.

Parameter
  • new_latest (Boolean) — New latest value
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.add_family "user" do |u|
    u.latest = true
  end
end

bigtable_table.families[0].latest #=> true

#type

def type() -> String

The type to convert the value in cells of this column family. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. The following BigQuery types are allowed:

  • BYTES
  • STRING
  • INTEGER
  • FLOAT
  • BOOLEAN

Default type is BYTES. This can be overridden on a column.

Returns
  • (String)
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.add_family "user" do |u|
    u.type = "STRING"
  end
end

bigtable_table.families[0].type #=> "STRING"

#type=

def type=(new_type)

Set the type to convert the value in cells of this column family. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. The following BigQuery types are allowed:

  • BYTES
  • STRING
  • INTEGER
  • FLOAT
  • BOOLEAN

Default type is BYTES. This can be overridden on a column.

Parameter
  • new_type (String) — New type value
Example
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url do |bt|
  bt.add_family "user" do |u|
    u.type = "STRING"
  end
end

bigtable_table.families[0].type #=> "STRING"