0
votes

New to Hbase, don't have hive or impala configured. :-( Now wanted to scan rows of a table based on multiple column values let say having Table A with 4 columns aa, ab, ac, ad. I wanted all rows of the table which satisfied the values condition of column ab & ad.

And other query is how to query on multiple tables assuming have external key are presents in the tables.

2

2 Answers

0
votes

Just to reiterate your scenarios: One HBase table named A, One Column Family CF1 and within it there are four column qualifiers i.e. aa, ab, ac, ad

Your requirement is to get rows which meet the two column qualifiers ab & ad conditions

The way for this implementation is to go with SingleColumnValueFilter. Create filter list, as many as you want (two filter list in your case) And add filters in the dependent order

If you have two different column families (A & B), then Scan 'A' , {COLUMNS => ['A:aa' , 'B:ab']}

In your second question, what do you mean by external key? If you are referring to a unique composite key identifier then explore secondary Index.

0
votes

For scanning rows on multiple columns in single hbase table you can use Hbase Api and the following java code might solve your problem.

 SingleColumnValueFilter f1 = new SingleColumnValueFilter(Bytes.toBytes("0"), Bytes.toBytes("EMP_KEY"), CompareFilter.CompareOp.LESS_OR_EQUAL, Bytes.toBytes(500));
  SingleColumnValueFilter f2 = new SingleColumnValueFilter(Bytes.toBytes("0"), Bytes.toBytes("DEPT_KEY"), CompareFilter.CompareOp.EQUAL, Bytes.toBytes(204));

  FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL); //could be FilterList.Operator.MUST_PASS_ALL instead
  filterList.addFilter(f1);
  filterList.addFilter(f2);

  Scan scan = new Scan();
  scan.setFilter(filterList);