Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

How to fetch single column from HBASE table

avatar
Rising Star

I have a table dept_tbl in HBase with 1 Column Family and 3 columns in it

cf1:dept_city, cf1:dept_name, cf1:dept_no

-------

I want to filter a column say dept_no and get the corresponding dept_name for it

Like: if dept_no=10, return dept_name=ACCOUNTING

-------

I applied filter as below:

scan 'dept_tbl',{FILTER => "MultipleColumnPrefixFilter('dept_name','dept_no') AND SingleColumnValueFilter('cf1','dept_no',=, 'binary:10')"}

-------

This returns me 2 columns: 'dept_name' and 'dept_no'

I need only 1 column 'dept_name' to be returned

-------

If I use MultipleColumnPrefixFilter('dept_name').. it gives me all rows as if it didnt check for filter of dept_no=10

I tried many combinations, I couldnt get it to return single column single row.

-------

Script to create the table:

create 'dept_tbl','cf1' put 'dept_tbl','R1','cf1:dept_no','10' put 'dept_tbl','R1','cf1:dept_name','ACCOUNTING' put 'dept_tbl','R1','cf1:dept_city','NEW YORK' put 'dept_tbl','R2','cf1:dept_no','20' put 'dept_tbl','R2','cf1:dept_name','RESEARCH' put 'dept_tbl','R2','cf1:dept_city','DALLAS' put 'dept_tbl','R3','cf1:dept_no','30' put 'dept_tbl','R3','cf1:dept_name','SALES' put 'dept_tbl','R3','cf1:dept_city','CHICAGO' put 'dept_tbl','R4','cf1:dept_no','40' put 'dept_tbl','R4','cf1:dept_name','OPERATIONS' put 'dept_tbl','R4','cf1:dept_city','BOSTON'

1 ACCEPTED SOLUTION

avatar
New Member

@Anubhav Raikar

Use reverse order of the filters:

scan 'dept_tbl',{FILTER => "SingleColumnValueFilter('cf1','dept_no',=,'binary:10') AND MultipleColumnPrefixFilter('dept_name')"}

The order of the filter matters here.

View solution in original post

2 REPLIES 2

avatar
New Member

@Anubhav Raikar

Use reverse order of the filters:

scan 'dept_tbl',{FILTER => "SingleColumnValueFilter('cf1','dept_no',=,'binary:10') AND MultipleColumnPrefixFilter('dept_name')"}

The order of the filter matters here.

avatar
Rising Star

whoaaa.. yes.. it works.. good to know the order matters.. thank you!