Support Questions

Find answers, ask questions, and share your expertise

Combine few hbase shell commands

avatar
Explorer

Hey,

I have a hbase table with 4 columns. I want to search for a string in column1 and get the value of column2 from every row, where I get a match. I works with these two codelines

scan 'table', { COLUMNS => 'column1', FILTER => "ValueFilter(=, 'substring:value')"}

Then foreach row: get 'table', $row, {COLUMNS => 'column2'}

How can I get the result (e.g. 'value1, value2, value3') by executing only one command?

best regards

J.H.

1 ACCEPTED SOLUTION

avatar
Master Collaborator

You can use SingleColumnValueFilter on 'column1'

Meanwhile, specify all the columns you want to retrieve using COLUMNS.

View solution in original post

3 REPLIES 3

avatar
Master Collaborator

You can use SingleColumnValueFilter on 'column1'

Meanwhile, specify all the columns you want to retrieve using COLUMNS.

avatar
Explorer

@Ted Yu

Thank you for the help. Maybe you can give me an example how to use it, because I get only errors and the examples which I found are not for the shell.

avatar
Master Collaborator

Please take a look at hbase-shell//src/test/ruby/hbase/table_test.rb for sample syntax where x is column family:

@test_table._scan_internal(FILTER => "SingleColumnValueFilter('x', 'a', >=, 'binary:\x82', true, true)", COLUMNS => 'x:a, x:b'