Skip to content

Bigtable: add filter region tag to hello world #1878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions bigtable/hello/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
"""

import argparse
# [START dependencies]
import datetime

from google.cloud import bigtable
from google.cloud.bigtable import column_family
from google.cloud.bigtable import row_filters
# [END dependencies]


def main(project_id, instance_id, table_id):
Expand Down Expand Up @@ -82,14 +84,19 @@ def main(project_id, instance_id, table_id):
table.mutate_rows(rows)
# [END writing_rows]

# [START creating_a_filter]
# Create a filter to only retrieve the most recent version of the cell
# for each column accross entire row.
row_filter = row_filters.CellsColumnLimitFilter(1)
# [END creating_a_filter]

# [START getting_a_row]
print('Getting a single greeting by row key.')
key = 'greeting0'.encode()

# Only retrieve the most recent version of the cell.
row_filter = row_filters.CellsColumnLimitFilter(1)
row = table.read_row(key, row_filter)
print(row.cell_value(column_family_id, column))
cell = row.cells[column_family_id][column][0]
print(cell.value.decode('utf-8'))
# [END getting_a_row]

# [START scanning_all_rows]
Expand Down