From c55e32b37a91be576979584999047d96c5566efa Mon Sep 17 00:00:00 2001 From: Akihiko Kusanagi Date: Tue, 5 Jun 2018 23:12:13 +0900 Subject: [PATCH] DRILL-4020: The not-equal operator returns incorrect results when used 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 --- .../exec/store/hbase/HBaseFilterBuilder.java | 1 + .../drill/hbase/TestHBaseFilterPushDown.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseFilterBuilder.java b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseFilterBuilder.java index 8d2e8ffd7ce..6e1efe512c9 100644 --- a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseFilterBuilder.java +++ b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseFilterBuilder.java @@ -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; } diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseFilterPushDown.java b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseFilterPushDown.java index 0e14cb183e2..c17b00ee622 100644 --- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseFilterPushDown.java +++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseFilterPushDown.java @@ -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});