BigTable read_rows usage

50 Views Asked by At

I wanted to use read_rows method as part of BigTable python API as it has support for retry object compared to read_row.

I see this documentation and the code works fine when records I am looking for exists in BigTable but if not, I still see it returns the "google.cloud.bigtable.row_data.PartialRowsData" object which can be used to retrieve the records. I am trying to find a way to identify if read_rows is not returning any records.

Attached code snippet below does not even return None object for the last 3 print statements if a record is not present in BigTable. But if the records exists, it properly returns the output for the print statements. Appreciate any inputs here to help me identify properly when it is not returning records.

client = bigtable.Client(project='xxxx', admin=True)
instance = client.instance('xxx')
table = instance.table('xxx')
row_set = RowSet()
row_set.add_row_key(b"12341#49")


rows = table.read_rows(row_set=row_set,retry=retry.Retry(
    predicate=if_exception_type(exceptions.ServiceUnavailable, exceptions.DeadlineExceeded),
    initial=1.0,
    maximum=60.0, # 60 seconds
    multiplier=2.0,
    deadline=600.0,  # 10 minutes
))

for rec in rows:
    print(rec)
    print(type(rec))
    cell = rec.cells['acq_details']['pk'.encode()][0]
    print(cell.value.decode("utf-8")=='12341#49')
0

There are 0 best solutions below