Skip to content

Conversation

@aneepct
Copy link
Contributor

@aneepct aneepct commented May 22, 2018

Add methods on Table to delete rows by prefix and truncate all rows.

  1. truncate
  2. drop_by_prefix

@aneepct aneepct requested a review from lukesneeringer as a code owner May 22, 2018 11:42
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 22, 2018
self.name)
return response_iterator

def truncate(self, timeout=60):

This comment was marked as spam.

delete_all_data_from_table=True,
timeout=timeout)

def drop_by_prefix(self, row_key_prefix, timeout=60):

This comment was marked as spam.

@tseaver tseaver added the api: bigtable Issues related to the Bigtable API. label May 22, 2018
@aneepct
Copy link
Contributor Author

aneepct commented May 29, 2018

@sduskis Fixed please review


result = table.truncate()

self.assertEqual(result, expected_result)

This comment was marked as spam.

This comment was marked as spam.


self.assertEqual(result, expected_result)

def test_drop_by_prefix_w_timestamp(self):

This comment was marked as spam.


data_api = bigtable_client.BigtableClient(mock.Mock())
table_api = bigtable_table_admin_client.BigtableTableAdminClient(
mock.Mock())

This comment was marked as spam.


data_api = bigtable_client.BigtableClient(mock.Mock())
table_api = bigtable_table_admin_client.BigtableTableAdminClient(
mock.Mock())

This comment was marked as spam.


data_api = bigtable_client.BigtableClient(mock.Mock())
table_api = bigtable_table_admin_client.BigtableTableAdminClient(
mock.Mock())

This comment was marked as spam.

Config.CLIENT = Client(admin=True, credentials=credentials)
else:
Config.CLIENT = Client(admin=True)
Config.CLIENT = Client(project='grass-clump-479', admin=True)

This comment was marked as spam.

This comment was marked as spam.

Copy link
Contributor

@sduskis sduskis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good to go when @tseaver is

row_keys = [
'row_key_1', 'row_key_2', 'row_key_3', 'row_key_4', 'row_key_5',
'row_key_pr_1', 'row_key_pr_2', 'row_key_pr_3', 'row_key_pr_4',
'row_key_pr_5']

This comment was marked as spam.

row_keys = [
'row_key_1', 'row_key_2', 'row_key_3', 'row_key_4', 'row_key_5',
'row_key_pr_1', 'row_key_pr_2', 'row_key_pr_3', 'row_key_pr_4',
'row_key_pr_5']

This comment was marked as spam.

@zakons
Copy link
Contributor

zakons commented Jun 11, 2018

@tseaver Ready to merge? Thanks.

@tseaver tseaver merged commit 5f39feb into googleapis:master Jun 11, 2018
@tseaver
Copy link
Contributor

tseaver commented Jun 12, 2018

@aneepct One of the system tests added by this PR is failing on CI this morning 1 2 3 4:

____________________ TestDataAPI.test_drop_by_prefix_table _____________________

self = <tests.system.TestDataAPI testMethod=test_drop_by_prefix_table>

    def test_drop_by_prefix_table(self):
        row_keys = [
            b'row_key_1', b'row_key_2', b'row_key_3', b'row_key_4',
            b'row_key_5', b'row_key_pr_1', b'row_key_pr_2', b'row_key_pr_3',
            b'row_key_pr_4', b'row_key_pr_5']
    
        for row_key in row_keys:
            row = self._table.row(row_key)
            row.set_cell(COLUMN_FAMILY_ID1, COL_NAME1, CELL_VAL1)
            row.commit()
            self.rows_to_delete.append(row)
    
        self._table.drop_by_prefix(row_key_prefix='row_key_pr', timeout=200)
    
        read_rows = self._table.yield_rows()
        expected_rows_count = 5
        read_rows_count = 0
    
        for row in read_rows:
            if row.row_key.decode('utf-8') in row_keys:
                read_rows_count += 1
    
>       self.assertEqual(expected_rows_count, read_rows_count)
E       AssertionError: 5 != 0

tseaver added a commit that referenced this pull request Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants