use of org.apache.phoenix.filter.RowKeyComparisonFilter in project phoenix by apache.
the class WhereOptimizerTest method testRVCExpressionWithSubsetOfPKCols.
/**
* With only a subset of row key cols present (which includes the leading key),
* Phoenix should have optimized the start row for the scan to include the
* row keys cols that occur contiguously in the RVC.
*
* Table entity_history has the row key defined as (organization_id, parent_id, created_date, entity_history_id).
* This test uses (organization_id, parent_id, entity_id) in RVC. So the start row should be comprised of
* organization_id and parent_id.
* @throws SQLException
*/
@Test
public void testRVCExpressionWithSubsetOfPKCols() throws SQLException {
String tenantId = "000000000000001";
String parentId = "000000000000002";
String entityHistId = "000000000000003";
String query = "select * from entity_history where (organization_id, parent_id, entity_history_id) >= (?,?,?)";
List<Object> binds = Arrays.<Object>asList(tenantId, parentId, entityHistId);
StatementContext context = compileStatement(query, binds);
Scan scan = context.getScan();
Filter filter = scan.getFilter();
assertNotNull(filter);
assertTrue(filter instanceof RowKeyComparisonFilter);
byte[] expectedStartRow = ByteUtil.concat(PVarchar.INSTANCE.toBytes(tenantId), PVarchar.INSTANCE.toBytes(parentId));
assertArrayEquals(expectedStartRow, scan.getStartRow());
assertArrayEquals(HConstants.EMPTY_END_ROW, scan.getStopRow());
}
Aggregations