drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ar...@apache.org
Subject [drill] branch master updated: DRILL-6489: Fix filter push down for Hbase & Mapr-DB binary tables when convert function is used in a view
Date Wed, 13 Jun 2018 09:50:52 GMT
This is an automated email from the ASF dual-hosted git repository.

arina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git


The following commit(s) were added to refs/heads/master by this push:
     new 63d0251  DRILL-6489: Fix filter push down for Hbase & Mapr-DB binary tables when
convert function is used in a view
63d0251 is described below

commit 63d0251502ac7a3af5a761b1a70a958ca0be1ae1
Author: Arina Ielchiieva <arina.yelchiyeva@gmail.com>
AuthorDate: Tue Jun 12 14:46:34 2018 +0000

    DRILL-6489: Fix filter push down for Hbase & Mapr-DB binary tables when convert function
is used in a view
---
 .../exec/store/hbase/CompareFunctionsProcessor.java     | 17 +++++++++++++++++
 .../org/apache/drill/hbase/TestHBaseFilterPushDown.java | 16 ++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/CompareFunctionsProcessor.java
b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/CompareFunctionsProcessor.java
index 0672b53..59df4e2 100644
--- a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/CompareFunctionsProcessor.java
+++ b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/CompareFunctionsProcessor.java
@@ -22,6 +22,8 @@ import io.netty.buffer.Unpooled;
 
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.drill.common.expression.CastExpression;
 import org.apache.drill.common.expression.ConvertExpression;
@@ -51,6 +53,10 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 
 public class CompareFunctionsProcessor extends AbstractExprVisitor<Boolean, LogicalExpression,
RuntimeException> {
+
+  // to check that function name starts with convert_from disregarding the case and has encoding
after
+  private static final Pattern convertFromPattern = Pattern.compile(String.format("^%s(.+)",
ConvertExpression.CONVERT_FROM), Pattern.CASE_INSENSITIVE);
+
   private byte[] value;
   private boolean success;
   private boolean isEqualityFn;
@@ -511,6 +517,17 @@ public class CompareFunctionsProcessor extends AbstractExprVisitor<Boolean,
Logi
     return false;
   }
 
+  @Override
+  public Boolean visitFunctionCall(FunctionCall call, LogicalExpression valueArg) {
+    Matcher matcher = convertFromPattern.matcher(call.getName());
+    if (matcher.find()) {
+      // convert function call to ConvertExpression
+      ConvertExpression convert = new ConvertExpression(ConvertExpression.CONVERT_FROM, matcher.group(1),
call.args.get(0), call.getPosition());
+      return visitConvertExpression(convert, valueArg);
+    }
+    return false;
+  }
+
   protected static ByteBuf newByteBuf(int size, boolean bigEndian) {
     return Unpooled.wrappedBuffer(new byte[size])
         .order(bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN)
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 0e14cb1..e6eff11 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
@@ -780,5 +780,21 @@ public class TestHBaseFilterPushDown extends BaseHBaseTest {
     runHBaseSQLVerifyCount(sql, 2);
   }
 
+  @Test
+  public void testConvertFromPushDownWithView() throws Exception {
+    test("create view dfs.tmp.pd_view as\n" +
+       "select convert_from(byte_substr(row_key, 1, 8), 'date_epoch_be') as d\n" +
+       "from hbase.`TestTableCompositeDate`");
+
+    String query = "select d from dfs.tmp.pd_view where d > date '2015-06-13' and d <
DATE '2015-06-18'";
+    String[] expectedPlan = {
+        "startRow=\\\\x00\\\\x00\\\\x01M\\\\xEF\\]\\\\xA0\\\\x00, " +
+        "stopRow=\\\\x00\\\\x00\\\\x01N\\\\x03\\\\xF7\\\\x10\\\\x00, " +
+        "filter=null"};
+    String[] excludedPlan ={"Filter\\("};
+    PlanTestBase.testPlanMatchingPatterns(query, expectedPlan, excludedPlan);
+
+    runHBaseSQLVerifyCount(query, 12);
+  }
 }
 

-- 
To stop receiving notification emails like this one, please contact
arina@apache.org.

Mime
View raw message