Happybase: How can I do a query for specific columns by regex-statement

121 Views Asked by At

I have several columns by the schema family:qualifier. Here are the columns with the values for the first row:

b'data:name': b'test33',  
b'data:appender.0.more.deep.0.name': b'nested', 
b'data:appender.0.more.deep.0.value': b'4711', 
b'data:appender.0.more.deep.1.name': b'nested2', 
b'data:appender.0.more.deep.1.value': b'42', 
b'data:appender.0.more.name': b'Alex', 
b'data:appender.0.more.process': b'buy', 
b'data:appender.0.more.value': b'1.0', 
b'data:appender.0.id': b'32542352352354432', 
b'data:appender.1.more.name': b'Andrew', 
b'data:appender.1.more.process': b'sell', 
b'data:appender.1.more.value': b'20.0', 
b'data:appender.1.id': b'deaf3232432', 
…
b'data:appender.47110.more.deep.name': b'3rfsdf3', 
b'data:appender.47110.more.deep.value': b'412', 
b'data:appender.47110.more.name': b'Jenny', 
b'data:appender.47110.more.process': b'buy', 
b'data:appender.47110.more.value': b'10.0', 
b'data:date': b'2020-11-02 12:18:49.479229', 
b'data:ob.0.cd': b'902359874598459834985093', 
b'data:ob.0.n': b'235a3ff4234234',    
b'data:s.c': b'hco', 
b'data:s.s.p': b'nm',  
b'data:id': b'5345345'

The question is how can I query the row with happybase where at least one column 'data:appender.NumberX.more.deep.NumberY.value' has the value 42. The maximum number of NumberX or NumberY is not known to me. NumberY need not necessarily exist as you can see in the example above. The same applies to NumberX.

I don't know how do I query this with python/happybase for columns because I am new to HBase/happybase. First I would to detect the numbers for the columnnames like this re.findall(".[0-9]*.", key) and then replace it with a dot. I want to create a query like this data:appender.more.deep.name that looks in all possible columns (e.g. in 'data:appender.47110.more.deep.value' or 'data:appender.0.more.deep.0.value' or 'data:appender.0.more.deep.1.value'

0

There are 0 best solutions below