Roy G
Roy G

Reputation: 949

How do I delete filtered rows in BigTable GCP

I trying to delete filtered rows in BigTable.

I have a table that has an empty value in a cell that I would like to remove the row from the table, I wrote a filter that select the relevant rows, but when I try to delete the rows, I get an error. enter code hereAttributeError: 'PartialRowData' object has no attribute 'delete'

I would like to know how should I Filter the relevant rows that base on the filter and delete them.

My code wrote in Python

col1_filter = row_filters.ColumnQualifierRegexFilter(b'customerId')
label1_filter = row_filters.ValueRegexFilter('')
chain1 = row_filters.RowFilterChain(filters=[col1_filter, label1_filter])

partial_rows = table.read_rows(filter_=chain1)

for row in partial_rows:
    row.delete()

Upvotes: 3

Views: 4293

Answers (1)

jszule
jszule

Reputation: 432

You get that error because the PartialRowsData does not have a delete function. You have to create a row from it (eg DirectRow), than you can call the delete function or delete_cell function on it.

Upvotes: 5

Related Questions