2
我在HBase中有一個表,其中漢字存儲在某個列中,比如'FLT:CREW_DEPT'。現在我需要過濾出'FLT:CREW_DEPT'等於某個值的所有行。當HBase的殼這樣做,它工作正常,如下圖所示當使用happybase掃描一個帶有中文字符的HBase表時,過濾器不起作用
scan 'PAX_EXP_FACT', {COLUMNS => ['FLT:CREW_DEPT'], FILTER => "SingleColumnValueFilter ('FLT', 'CREW_DEPT', =, 'binary:\xe4\xb8\x80\xe9\x83\xa8', true, true)", LIMIT => 5}
ROW COLUMN+CELL
CA101-20160808-PEK-001192753702 column=FLT:CREW_DEPT, timestamp=1500346136328, value=\xE4\xB8\x80\xE9\x83\xA8
CA101-20161103-PEK-001181988752 column=FLT:CREW_DEPT, timestamp=1500346230204, value=\xE4\xB8\x80\xE9\x83\xA8
CA101-20161105-PEK-000728690130 column=FLT:CREW_DEPT, timestamp=1500346244963, value=\xE4\xB8\x80\xE9\x83\xA8
CA101-20161201-PEK-006731936575 column=FLT:CREW_DEPT, timestamp=1500346233640, value=\xE4\xB8\x80\xE9\x83\xA8
CA101-20161212-PEK-001512808262 column=FLT:CREW_DEPT, timestamp=1500346223572, value=\xE4\xB8\x80\xE9\x83\xA8
5 row(s) in 0.0060 seconds
然而,使用happybase在Python做類似的事情的時候,什麼也沒有返回:返回
import happybase
import datetime
import pytz
connection = happybase.Connection('192.168.199.200', port=9090)
table = connection.table('PAX_EXP_FACT')
filter_str = ""
filter_str += "SingleColumnValueFilter('FLT', 'CREW_DEPT', =, 'binary:\xe4\xba\x8c\xe9\x83\xa8')"
results = table.scan(
filter=filter_str
# ,limit=100
)
count = 0
for key, data in results:
count += 1
print(data[b'FLT:CREW_DEPT'].decode('utf-8'))
print('No. of flight matches:', count)
connection.close()
0行...
任何人都可以幫忙嗎?非常感激!!!