Table

User friendly container for Google Cloud Bigtable Table.

class gcloud_bigtable.table.Table(table_id, cluster)[source]

Bases: object

Representation of a Google Cloud Bigtable Table.

Note

We don’t define any properties on a table other than the name. As the proto says, in a request:

The name field of the Table and all of its ColumnFamilies must be left blank, and will be populated in the response.

This leaves only the current_operation and granularity fields. The current_operation is only used for responses while granularity is an enum with only one value.

We can use a Table to:

Parameters:
  • table_id (string) – The ID of the table.
  • cluster (cluster.Cluster) – The cluster that owns the table.
client

Getter for table’s client.

Return type:client.Client
Returns:The client that owns this table.
cluster

Getter for table’s cluster.

Return type:cluster.Cluster
Returns:The cluster stored on the table.
column_family(column_family_id, gc_rule=None)[source]

Factory to create a column family associated with this table.

Parameters:
Return type:

column_family.ColumnFamily

Returns:

A column family owned by this table.

create(initial_split_keys=None, timeout_seconds=None)[source]

Creates this table.

Note

Though a _generated.bigtable_table_data_pb2.Table is also allowed (as the table property) in a create table request, we do not support it in this method. As mentioned in the Table docstring, the name is the only useful property in the table proto.

Note

A create request returns a _generated.bigtable_table_data_pb2.Table but we don’t use this response. The proto definition allows for the inclusion of a current_operation in the response, but in example usage so far, it seems the Bigtable API does not return any operation.

Parameters:
  • initial_split_keys (iterable of strings) – (Optional) List of row keys that will be used to initially split the table into several tablets (Tablets are similar to HBase regions). Given two split keys, "s1" and "s2", three tablets will be created, spanning the key ranges: [, s1), [s1, s2), [s2, ).
  • timeout_seconds (integer) – Number of seconds for request time-out. If not passed, defaults to value set on table.
delete(timeout_seconds=None)[source]

Delete this table.

Parameters:timeout_seconds (integer) – Number of seconds for request time-out. If not passed, defaults to value set on table.
list_column_families(timeout_seconds=None)[source]

Check if this table exists.

Parameters:timeout_seconds (integer) – Number of seconds for request time-out. If not passed, defaults to value set on table.
Return type:dictionary with string as keys and column_family.ColumnFamily as values
Returns:List of column families attached to this table.
Raises:ValueError if the column family name from the response does not agree with the computed name from the column family ID.
name

Table name used in requests.

Note

This property will not change if table_id does not, but the return value is not cached.

The table name is of the form

"projects/../zones/../clusters/../tables/{table_id}"
Return type:string
Returns:The table name.
rename(new_table_id, timeout_seconds=None)[source]

Rename this table.

Note

This cannot be used to move tables between clusters, zones, or projects.

Note

The Bigtable Table Admin API currently returns

BigtableTableService.RenameTable is not yet implemented

when this method is used. It’s unclear when this method will actually be supported by the API.

Parameters:
  • new_table_id (string) – The new name table ID.
  • timeout_seconds (integer) – Number of seconds for request time-out. If not passed, defaults to value set on table.
timeout_seconds

Getter for table’s default timeout seconds.

Return type:integer
Returns:The timeout seconds default stored on the table’s client.