How to get a list of keys from Cloud Bigtable cbt tool?

3.7k Views Asked by At

I am using cbt tool to inspect the data of some tables. I want to know what are the typical fields in the rows of my table. The only way to do this is to use cbt read. But cbt read select massive amounts of rows, which I don't want to do. I just want to find a few row keys so I can run cbt lookup <row-key> with them.

I'm doing this because BigTable is simply an enterprise-class HBase, thus it is a schema-less DB. The only way to find out the columns of the table is to inspect the records.

1

There are 1 best solutions below

2
On

To avoid massive read amount of rows and select few row keys only, you can use [start=<row-key>] and [end=<row-key>] or with count=<n> to limit the number of rows read, here's the documentation.

For example, using [start=<row-key>] and [end=<row-key>] :

cbt read my-table start=r2 end=r4

output:

----------------------------------------
r2
  cf1:c1                                   @ 2021/08/24-02:34:56.750000
    "test2-value2"
----------------------------------------
r3
  cf1:c1                                   @ 2021/08/24-02:38:36.748000
    "test3-value3"

with count=<n>:

cbt read my-table start=r2 end=r4 count=1

output:

----------------------------------------
r2
  cf1:c1                                   @ 2021/08/24-02:34:56.750000
    "test2-value2"