I have 3 cols {col1, col2, col3} in a col family (CF). I'd like to write a scan such that I select all rows that have col1='val1' and col2='val2' and (col3 is missing or col3 is null)
.
Doing this in Java - sorry I'm totally new to hbase ;-)
I had a lot of trouble finding an answer to this myself online. I finally figured it out, and its quite simple - just unanswered:
Scan scanner = new Scan();
SingleColumnValueFilter filter = new SingleColumnValueFilter(
Bytes.toBytes( "some family" ),
Bytes.toBytes( "some column" ),
CompareFilter.CompareOp.EQUAL,
Bytes.toBytes( "" )
);
filter.setFilterIfMissing( false );
scanner.setFilter( filter );
return scanner;
The key parts of the solution are setting setFilterIfMissing
to false and comparing with an empty string.