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.
- qualifier (String) — Qualifier of the column. See Google::Cloud::Bigquery::External::BigtableSource::Column#qualifier.
-
as (String) (defaults to: nil) — A valid identifier to be used as the column
field name if the qualifier is not a valid BigQuery field
identifier (i.e. does not match
[a-zA-Z][a-zA-Z0-9_]*
). See Google::Cloud::Bigquery::External::BigtableSource::Column#field_name.
- (column) — a block for setting the column
- column (BigtableSource::Column) — the column object
- (Array<BigtableSource::Column>)
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.
- qualifier (String) — Qualifier of the column. See Google::Cloud::Bigquery::External::BigtableSource::Column#qualifier.
-
as (String) (defaults to: nil) — A valid identifier to be used as the column
field name if the qualifier is not a valid BigQuery field
identifier (i.e. does not match
[a-zA-Z][a-zA-Z0-9_]*
). See Google::Cloud::Bigquery::External::BigtableSource::Column#field_name.
- (column) — a block for setting the column
- column (BigtableSource::Column) — the column object
- (Array<BigtableSource::Column>)
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
- qualifier (String) — Qualifier of the column. See Google::Cloud::Bigquery::External::BigtableSource::Column#qualifier.
-
as (String) (defaults to: nil) — A valid identifier to be used as the column
field name if the qualifier is not a valid BigQuery field
identifier (i.e. does not match
[a-zA-Z][a-zA-Z0-9_]*
). See Google::Cloud::Bigquery::External::BigtableSource::Column#field_name. - type (String) (defaults to: nil) — The type to convert the value in cells of this column. See Google::Cloud::Bigquery::External::BigtableSource::Column#type. The following BigQuery types are allowed:
- (column) — a block for setting the column
- column (BigtableSource::Column) — the column object
- (Array<BigtableSource::Column>)
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.
- qualifier (String) — Qualifier of the column. See Google::Cloud::Bigquery::External::BigtableSource::Column#qualifier.
-
as (String) (defaults to: nil) — A valid identifier to be used as the column
field name if the qualifier is not a valid BigQuery field
identifier (i.e. does not match
[a-zA-Z][a-zA-Z0-9_]*
). See Google::Cloud::Bigquery::External::BigtableSource::Column#field_name.
- (column) — a block for setting the column
- column (BigtableSource::Column) — the column object
- (Array<BigtableSource::Column>)
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.
- qualifier (String) — Qualifier of the column. See Google::Cloud::Bigquery::External::BigtableSource::Column#qualifier.
-
as (String) (defaults to: nil) — A valid identifier to be used as the column
field name if the qualifier is not a valid BigQuery field
identifier (i.e. does not match
[a-zA-Z][a-zA-Z0-9_]*
). See Google::Cloud::Bigquery::External::BigtableSource::Column#field_name.
- (column) — a block for setting the column
- column (BigtableSource::Column) — the column object
- (Array<BigtableSource::Column>)
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.
- qualifier (String) — Qualifier of the column. See Google::Cloud::Bigquery::External::BigtableSource::Column#qualifier.
-
as (String) (defaults to: nil) — A valid identifier to be used as the column
field name if the qualifier is not a valid BigQuery field
identifier (i.e. does not match
[a-zA-Z][a-zA-Z0-9_]*
). See Google::Cloud::Bigquery::External::BigtableSource::Column#field_name.
- (column) — a block for setting the column
- column (BigtableSource::Column) — the column object
- (Array<BigtableSource::Column>)
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.
- (Array<BigtableSource::Column>)
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
.
- (String)
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 HBaseBytes.toBytes
family of functions. This can be overridden on a column.
- new_encoding (String) — New encoding value
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.
- (String)
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.
- new_family_id (String) — New family_id value
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.
- (Boolean)
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.
- new_latest (Boolean) — New latest value
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.
- (String)
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.
- new_type (String) — New type value
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"