1.64.1 (latest) 1.64.0 1.63.1 1.62.0 1.61.1 1.60.0 1.59.0 1.58.0 1.57.0 1.56.0 1.55.0 1.54.0 1.53.0 1.52.1 1.51.1 1.50.0 1.49.1 1.48.1 1.47.0 1.46.1 1.45.0 1.44.2 1.43.1 1.42.0 1.41.0 1.40.0 1.39.0 1.38.1 Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::External::BigtableSource.

## BigtableSource

[BigtableSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-BigtableSource "Google::Cloud::Bigquery::External::BigtableSource (class)") is a subclass of [DataSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource "Google::Cloud::Bigquery::External::DataSource (class)") and
represents a Bigtable external data source that can be queried from
directly, even though the data is not stored in BigQuery. Instead of
loading or streaming the data, this object references the external
data source.

## Inherits

- [Google::Cloud::Bigquery::External::DataSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource)

## Example

```ruby
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_family

    def add_family(family_id, encoding: nil, latest: nil, type: nil) { |family| ... } -> BigtableSource::ColumnFamily

Add a column family to expose in the table schema along with its
types. Columns belonging to the column family may also be exposed.
**Parameters**

- **family_id** (String) --- Identifier of the column family. See [ColumnFamily#family_id](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-BigtableSource-ColumnFamily#Google__Cloud__Bigquery__External__BigtableSource__ColumnFamily_family_id_instance_ "Google::Cloud::Bigquery::External::BigtableSource::ColumnFamily#family_id (method)").
- **encoding** (String) *(defaults to: nil)* --- The encoding of the values when the type is not `STRING`. See [ColumnFamily#encoding](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-BigtableSource-ColumnFamily#Google__Cloud__Bigquery__External__BigtableSource__ColumnFamily_encoding_instance_ "Google::Cloud::Bigquery::External::BigtableSource::ColumnFamily#encoding (method)").
- **latest** (Boolean) *(defaults to: nil)* --- Whether only the latest version of value are exposed for all columns in this column family. See [ColumnFamily#latest](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-BigtableSource-ColumnFamily#Google__Cloud__Bigquery__External__BigtableSource__ColumnFamily_latest_instance_ "Google::Cloud::Bigquery::External::BigtableSource::ColumnFamily#latest (method)").
- **type** (String) *(defaults to: nil)* --- The type to convert the value in cells of this column. See [ColumnFamily#type](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-BigtableSource-ColumnFamily#Google__Cloud__Bigquery__External__BigtableSource__ColumnFamily_type_instance_ "Google::Cloud::Bigquery::External::BigtableSource::ColumnFamily#type (method)").
**Yields**

- (family) --- a block for setting the family
**Yield Parameter**

- **family** ([BigtableSource::ColumnFamily](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-BigtableSource-ColumnFamily)) --- the family object
**Returns**

- ([BigtableSource::ColumnFamily](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-BigtableSource-ColumnFamily))
**Example**

```ruby
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
```

### #families

    def families() -> Array<BigtableSource::ColumnFamily>

List of column families to expose in the table schema along with
their types. This list restricts the column families that can be
referenced in queries and specifies their value types. You can use
this list to do type conversions - see
[ColumnFamily#type](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-BigtableSource-ColumnFamily#Google__Cloud__Bigquery__External__BigtableSource__ColumnFamily_type_instance_ "Google::Cloud::Bigquery::External::BigtableSource::ColumnFamily#type (method)") for more details. If you leave
this list empty, all column families are present in the table schema
and their values are read as `BYTES`. During a query only the column
families referenced in that query are read from Bigtable.
**Returns**

- (Array\<[BigtableSource::ColumnFamily](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-BigtableSource-ColumnFamily)\>)
**Example**

```ruby
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.count #=> 1
```

### #rowkey_as_string

    def rowkey_as_string() -> Boolean

Whether the rowkey column families will be read and converted to
string. Otherwise they are read with `BYTES` type values and users
need to manually cast them with `CAST` if necessary. The default
value is `false`.
**Returns**

- (Boolean)
**Example**

```ruby
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
end

bigtable_table.rowkey_as_string #=> true
```

### #rowkey_as_string=

    def rowkey_as_string=(row_rowkey)

Set the number of rows at the top of a sheet that BigQuery will skip
when reading the data.
**Parameter**

- **row_rowkey** (Boolean) --- New rowkey_as_string value
**Example**

```ruby
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
end

bigtable_table.rowkey_as_string #=> true
```