Skip to content

Commit dfc070c

Browse files
committed
fixed table setup
1 parent f647dbc commit dfc070c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

samples/utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717

1818
from google.cloud import bigtable
19+
from google.cloud.bigtable.column_family import ColumnFamily
1920
from google.api_core import exceptions
2021
from google.api_core.retry import Retry
2122
from google.api_core.retry import if_exception_type
@@ -59,12 +60,18 @@ def create_table(project, instance_id, table_id, column_families={}):
5960
if table.exists():
6061
table.delete()
6162

63+
# convert column families to pb if needed
64+
pb_families = {
65+
id: ColumnFamily(id, table, rule).to_pb() if not isinstance(rule, ColumnFamily) else rule
66+
for (id, rule) in column_families.items()
67+
}
68+
6269
# create table using gapic layer
6370
instance._client.table_admin_client.create_table(
6471
request={
6572
"parent": instance.name,
6673
"table_id": table_id,
67-
"table": {"column_families": column_families},
74+
"table": {"column_families": pb_families},
6875
}
6976
)
7077

0 commit comments

Comments
 (0)