Question

I have some questions about HBase Shell Command Tool:

1: How to list all column family names (just names!) in a table?
2: How to count the number of rows in a column family?
Était-ce utile?

La solution

1: How to list all column family names (just names!) in a table?

Not possible OOTB. But you could do something like this :

echo "scan 'table'" | bin/hbase shell | awk -F'=' '{print $2}' | awk -F ':' '{print $1}'

2: How to count the number of rows in a column family?

What do you mean by this? Do you intend to ask How to count the number of column families in a rows? If this is what you need, try this :

echo "scan 'table'" | bin/hbase shell | grep cf | wc -l

Autres conseils

Use describe, it will show the column families as NAME=> 'columnfamilyname'

I have a listColumns script based on Tariq's answer that limits the scan (because I'd like it to finish in my lifetime).

echo "scan '$1', LIMIT => 1" | hbase shell | awk '{print $2}' | grep column | sort | uniq | awk -F = '{print $2} '

Obviously you run the risk of rows having different columns.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top