Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

how to get Readable result in Hbase shell


how to get Readable result in Hbase shell

Expert Contributor


hbase(main):023:0> scan 'test:test'
ROW                                   COLUMN+CELL                                                                                               
 11                                   column=cf:name, timestamp=1548146515498, value=1111111                                                    
 111                                  column=cf:name, timestamp=1543544919345, value=111                                                        
 CDH5.10.2                            column=cf:name, timestamp=1545118090526, value=this is a test                                             
 \xE6\x88\x91                         column=cf:name, timestamp=1548144898631, value=1111  


as you can see, "\xE6\x88\x91" is not readable, it seems it's hex mode ,  who can tell me  how to do get this value readable  ?




Re: how to get Readable result in Hbase shell

Master Guru

The HBase shell currently only prints out ASCII printable range of characters, and not unicode, to make it easier to pass around values. In practice, HBase keys are often not designed to be readable and are binary forms (such as encoded integers of hashed values, etc.).


That said, the HBase shell is a programmable JRuby console, so you can use HBase Java APIs within it to get a desired output if you are going to be relying on HBase shell for your scripting work.


Here's a simple example:


hbase(main):013:0> config = org.apache.hadoop.hbase.HBaseConfiguration.create
=> #<Java::OrgApacheHadoopConf::Configuration:0x4a864d4d>

hbase(main):014:0> table =, 't')
=> #<Java::OrgApacheHadoopHbaseClient::HTable:0x5e85c21b>

hbase(main):015:0> scanner = table.getScanner(
=> #<Java::OrgApacheHadoopHbaseClient::ClientScanner:0x5aa76ad2>

hbase(main):030:0> scanner.each do |row|
hbase(main):031:1* key = String.from_java_bytes(row.getRow())
hbase(main):032:1> puts "'#{key}'"
hbase(main):033:1> end