Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using multiple column filters with HappyBase

I'm using HappyBase as Python Thrift client to connect to HBase.

I'm scanning the table and need to use filters on multiple columns. How this can be achieved in HappyBase? Java gives an option for this using Filterlist.

like image 265
user2645822 Avatar asked Mar 04 '26 02:03

user2645822


1 Answers

As specified on the github page, Happybase is using Thrift. You should use the same syntax as thrift.

On your scan function, you can specify a filter string :

SingleColumnValueFilter(‘’, ‘, , ‘’)

For example, if you need to scan all rows with the column blah:blouh = batman :

hbase_table.scan(filter="SingleColumnValueFilter ('blah','blouh',=,'regexstring:^batman$')")

You can use AND or OR to put several filters, just remember to surround everything with parenthesis.

Thrift Documentation : http://hbase.apache.org/book/thrift.html

Be careful when creating filters on string, you will have to use a specific comparator (like regexstring in my example).

like image 55
SIkwan Avatar answered Mar 06 '26 15:03

SIkwan