You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2014/05/04 18:55:31 UTC

[09/21] git commit: DRILL-452: Conversion functions for external data types

DRILL-452: Conversion functions for external data types

* Length need not be a parameter in varchar* functions.
* Added test cases for UTF8 conversion.


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/beeaf9e8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/beeaf9e8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/beeaf9e8

Branch: refs/heads/master
Commit: beeaf9e8fb482cc2bde1838e5f152bff130d4135
Parents: 2bfa2c1
Author: Aditya Kishore <ad...@maprtech.com>
Authored: Fri Apr 25 16:02:32 2014 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Sat May 3 18:46:30 2014 -0700

----------------------------------------------------------------------
 .../drill/exec/expr/fn/impl/conv/UTF16ConvertFrom.java       | 8 +-------
 .../apache/drill/exec/expr/fn/impl/conv/UTF16ConvertTo.java  | 8 +-------
 .../apache/drill/exec/expr/fn/impl/conv/UTF8ConvertFrom.java | 8 +-------
 .../apache/drill/exec/expr/fn/impl/conv/UTF8ConvertTo.java   | 8 +-------
 .../drill/exec/physical/impl/TestConvertFunctions.java       | 7 +++++++
 5 files changed, 11 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/beeaf9e8/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF16ConvertFrom.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF16ConvertFrom.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF16ConvertFrom.java
index d8dfe26..82562c8 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF16ConvertFrom.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF16ConvertFrom.java
@@ -24,7 +24,6 @@ import org.apache.drill.exec.expr.annotations.FunctionTemplate.FunctionScope;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
 import org.apache.drill.exec.expr.annotations.Output;
 import org.apache.drill.exec.expr.annotations.Param;
-import org.apache.drill.exec.expr.holders.BigIntHolder;
 import org.apache.drill.exec.expr.holders.Var16CharHolder;
 import org.apache.drill.exec.expr.holders.VarBinaryHolder;
 import org.apache.drill.exec.record.RecordBatch;
@@ -33,7 +32,6 @@ import org.apache.drill.exec.record.RecordBatch;
 public class UTF16ConvertFrom implements DrillSimpleFunc {
 
   @Param VarBinaryHolder in;
-  @Param BigIntHolder length;
   @Output Var16CharHolder out;
 
   @Override
@@ -43,10 +41,6 @@ public class UTF16ConvertFrom implements DrillSimpleFunc {
   public void eval() {
     out.buffer = in.buffer;
     out.start =  in.start;
-    if (in.end - in.start <= length.value) {
-      out.end = in.end;
-    } else {
-      out.end = out.start + (int) length.value;
-    }
+    out.end = in.end;
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/beeaf9e8/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF16ConvertTo.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF16ConvertTo.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF16ConvertTo.java
index b47918b..cff1851 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF16ConvertTo.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF16ConvertTo.java
@@ -24,7 +24,6 @@ import org.apache.drill.exec.expr.annotations.FunctionTemplate.FunctionScope;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
 import org.apache.drill.exec.expr.annotations.Output;
 import org.apache.drill.exec.expr.annotations.Param;
-import org.apache.drill.exec.expr.holders.BigIntHolder;
 import org.apache.drill.exec.expr.holders.Var16CharHolder;
 import org.apache.drill.exec.expr.holders.VarBinaryHolder;
 import org.apache.drill.exec.record.RecordBatch;
@@ -33,7 +32,6 @@ import org.apache.drill.exec.record.RecordBatch;
 public class UTF16ConvertTo implements DrillSimpleFunc {
 
   @Param Var16CharHolder in;
-  @Param BigIntHolder length;
   @Output VarBinaryHolder out;
 
   @Override
@@ -43,10 +41,6 @@ public class UTF16ConvertTo implements DrillSimpleFunc {
   public void eval() {
     out.buffer = in.buffer;
     out.start =  in.start;
-    if (in.end - in.start <= length.value) {
-      out.end = in.end;
-    } else {
-      out.end = out.start + (int) length.value;
-    }
+    out.end = in.end;
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/beeaf9e8/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF8ConvertFrom.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF8ConvertFrom.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF8ConvertFrom.java
index b73ca98..a6f8901 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF8ConvertFrom.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF8ConvertFrom.java
@@ -24,7 +24,6 @@ import org.apache.drill.exec.expr.annotations.FunctionTemplate.FunctionScope;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
 import org.apache.drill.exec.expr.annotations.Output;
 import org.apache.drill.exec.expr.annotations.Param;
-import org.apache.drill.exec.expr.holders.BigIntHolder;
 import org.apache.drill.exec.expr.holders.VarBinaryHolder;
 import org.apache.drill.exec.expr.holders.VarCharHolder;
 import org.apache.drill.exec.record.RecordBatch;
@@ -33,7 +32,6 @@ import org.apache.drill.exec.record.RecordBatch;
 public class UTF8ConvertFrom implements DrillSimpleFunc {
 
   @Param VarBinaryHolder in;
-  @Param BigIntHolder length;
   @Output VarCharHolder out;
 
   @Override
@@ -43,10 +41,6 @@ public class UTF8ConvertFrom implements DrillSimpleFunc {
   public void eval() {
     out.buffer = in.buffer;
     out.start =  in.start;
-    if (in.end - in.start <= length.value) {
-      out.end = in.end;
-    } else {
-      out.end = out.start + (int) length.value;
-    }
+    out.end = in.end;
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/beeaf9e8/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF8ConvertTo.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF8ConvertTo.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF8ConvertTo.java
index 92770de..093d6b9 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF8ConvertTo.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/conv/UTF8ConvertTo.java
@@ -24,7 +24,6 @@ import org.apache.drill.exec.expr.annotations.FunctionTemplate.FunctionScope;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
 import org.apache.drill.exec.expr.annotations.Output;
 import org.apache.drill.exec.expr.annotations.Param;
-import org.apache.drill.exec.expr.holders.BigIntHolder;
 import org.apache.drill.exec.expr.holders.VarBinaryHolder;
 import org.apache.drill.exec.expr.holders.VarCharHolder;
 import org.apache.drill.exec.record.RecordBatch;
@@ -33,7 +32,6 @@ import org.apache.drill.exec.record.RecordBatch;
 public class UTF8ConvertTo implements DrillSimpleFunc {
 
   @Param VarCharHolder in;
-  @Param BigIntHolder length;
   @Output VarBinaryHolder out;
 
   @Override
@@ -43,10 +41,6 @@ public class UTF8ConvertTo implements DrillSimpleFunc {
   public void eval() {
     out.buffer = in.buffer;
     out.start =  in.start;
-    if (in.end - in.start <= length.value) {
-      out.end = in.end;
-    } else {
-      out.end = out.start + (int) length.value;
-    }
+    out.end = in.end;
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/beeaf9e8/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java
index 881495c..6476e0b 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java
@@ -348,6 +348,13 @@ public class TestConvertFunctions extends PopUnitTestBase {
   }
 
   @Test
+  public void testUTF8(@Injectable final DrillbitContext bitContext,
+      @Injectable UserServer.UserClientConnection connection) throws Throwable {
+    runTest(bitContext, connection, "convert_from(binary_string('apache_drill'), 'UTF8')", "apache_drill");
+    runTest(bitContext, connection, "convert_to('apache_drill', 'UTF8')", new byte[] {'a', 'p', 'a', 'c', 'h', 'e', '_', 'd', 'r', 'i', 'l', 'l'});
+  }
+
+  @Test
   public void testBigIntVarCharReturnTripConvertLogical() throws Exception {
     RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();