drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [02/17] git commit: DRILL-988: trunc(num) bugfix handle data loss
Date Mon, 21 Jul 2014 02:46:24 GMT
DRILL-988: trunc(num) bugfix handle data loss


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

Branch: refs/heads/master
Commit: 785aa5a254254e782d13fba562ec47ec0be7676d
Parents: 699851b
Author: Yash Sharma <yash.sharma@snapdeal.com>
Authored: Thu May 29 00:29:11 2014 +0530
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Sun Jul 20 16:26:35 2014 -0700

----------------------------------------------------------------------
 exec/java-exec/src/main/codegen/data/MathFunc.tdd            | 4 ++--
 exec/java-exec/src/main/codegen/templates/MathFunctions.java | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/785aa5a2/exec/java-exec/src/main/codegen/data/MathFunc.tdd
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/data/MathFunc.tdd b/exec/java-exec/src/main/codegen/data/MathFunc.tdd
index b5b5543..cdce365 100644
--- a/exec/java-exec/src/main/codegen/data/MathFunc.tdd
+++ b/exec/java-exec/src/main/codegen/data/MathFunc.tdd
@@ -82,7 +82,7 @@ unaryMathFunctions : [
       {input: "UInt8", outputType: "UInt8", castType: "long"}
      ]
    	},
-    {className: "Trunc", funcName: "trunc", javaFunc : "(long)", types: [
+    {className: "Trunc", funcName: "trunc", types: [
       {input: "Int",  outputType: "Int", castType: "int"},
       {input: "BigInt",  outputType: "BigInt", castType: "long"},
       {input: "Float4", outputType: "Float4", castType: "float"},
@@ -90,7 +90,7 @@ unaryMathFunctions : [
       {input: "SmallInt",  outputType: "SmallInt", castType: "short"},
       {input: "TinyInt",  outputType: "TinyInt", castType: "byte"},
       {input: "UInt1", outputType: "UInt1", castType: "byte"},
-      {input: "UInt2", outputType: "UInt2", castType: "char"},
+      {input: "UInt2", outputType: "UInt2", castType: "int", extraCast: "char"},
       {input: "UInt4", outputType: "UInt4", castType: "int"},
       {input: "UInt8", outputType: "UInt8", castType: "long"}
      ]

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/785aa5a2/exec/java-exec/src/main/codegen/templates/MathFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/MathFunctions.java b/exec/java-exec/src/main/codegen/templates/MathFunctions.java
index c4298fb..8986b8a 100644
--- a/exec/java-exec/src/main/codegen/templates/MathFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/MathFunctions.java
@@ -67,7 +67,13 @@ public class GMathFunctions{
     }
 
     public void eval() {
+
+      <#if func.funcName=='trunc'>
+      java.math.BigDecimal bd = new java.math.BigDecimal(String.valueOf(in.value)).setScale(0,
java.math.BigDecimal.ROUND_DOWN);
+      out.value = <#if type.extraCast ??>(${type.extraCast})</#if>bd.${type.castType}Value();
+      <#else>
       out.value =(${type.castType}) ${func.javaFunc}(in.value);
+      </#if>
     }
   }
   


Mime
View raw message