Skip to content
Permalink
Browse files
DRILL-4020: The not-equal operator returns incorrect results when use…
…d on the HBase row key

- Added a condition that checks if the filter to the scan specification doesn't have NOT_EQUAL operator
- Added testFilterPushDownRowKeyNotEqual() to TestHBaseFilterPushDown

closes #309
  • Loading branch information
nagix authored and vvysotskyi committed Jul 1, 2018
1 parent f481a7c commit e6a0cdd193ed1724d7cd1faedb5257c787f468b0
Showing 2 changed files with 19 additions and 0 deletions.
@@ -61,6 +61,7 @@ public HBaseScanSpec parseTree() {
* remove it since its effect is also achieved through startRow and stopRow.
*/
if (parsedSpec.filter instanceof RowFilter &&
((RowFilter)parsedSpec.filter).getOperator() != CompareOp.NOT_EQUAL &&
((RowFilter)parsedSpec.filter).getComparator() instanceof BinaryComparator) {
parsedSpec.filter = null;
}
@@ -44,6 +44,24 @@ public void testFilterPushDownRowKeyEqual() throws Exception {
PlanTestBase.testPlanMatchingPatterns(sqlHBase, expectedPlan, excludedPlan);
}

@Test
public void testFilterPushDownRowKeyNotEqual() throws Exception {
setColumnWidths(new int[] {8, 38, 38});
final String sql = "SELECT\n"
+ " *\n"
+ "FROM\n"
+ " hbase.`[TABLE_NAME]` tableName\n"
+ "WHERE\n"
+ " row_key <> 'b4'";

runHBaseSQLVerifyCount(sql, 7);

final String[] expectedPlan = {".*startRow=, stopRow=, filter=RowFilter \\(NOT_EQUAL, b4\\).*"};
final String[] excludedPlan ={};
final String sqlHBase = canonizeHBaseSQL(sql);
PlanTestBase.testPlanMatchingPatterns(sqlHBase, expectedPlan, excludedPlan);
}

@Test
public void testFilterPushDownRowKeyEqualWithItem() throws Exception {
setColumnWidths(new int[] {20, 30});

0 comments on commit e6a0cdd

Please sign in to comment.