carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenliang...@apache.org
Subject [05/50] [abbrv] incubator-carbondata git commit: handle decimal query (#789)
Date Wed, 20 Jul 2016 10:13:33 GMT
handle decimal query (#789)

LGTM

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

Branch: refs/heads/master
Commit: efc395165b0ab33bdd96eac0d62e60e19e8f4c53
Parents: 35648c3
Author: Jay <liujunjie9@huawei.com>
Authored: Fri Jul 15 14:43:14 2016 +0800
Committer: linyixin <linyixin@huawei.com>
Committed: Fri Jul 15 14:43:14 2016 +0800

----------------------------------------------------------------------
 .../query/expression/ExpressionResult.java        |  2 +-
 .../testsuite/bigdecimal/TestBigDecimal.scala     | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/efc39516/core/src/main/java/org/carbondata/query/expression/ExpressionResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/expression/ExpressionResult.java b/core/src/main/java/org/carbondata/query/expression/ExpressionResult.java
index 067f2d3..bc25873 100644
--- a/core/src/main/java/org/carbondata/query/expression/ExpressionResult.java
+++ b/core/src/main/java/org/carbondata/query/expression/ExpressionResult.java
@@ -216,7 +216,7 @@ public class ExpressionResult implements Comparable<ExpressionResult>
{
         case LongType:
           return new BigDecimal((long) value);
         case DoubleType:
-          return new BigDecimal((double) value);
+          return new BigDecimal(value.toString());
         case DecimalType:
           return new BigDecimal(value.toString());
         case TimestampType:

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/efc39516/integration/spark/src/test/scala/org/carbondata/spark/testsuite/bigdecimal/TestBigDecimal.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/bigdecimal/TestBigDecimal.scala
b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/bigdecimal/TestBigDecimal.scala
index c837f7b..3763e35 100644
--- a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/bigdecimal/TestBigDecimal.scala
+++ b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/bigdecimal/TestBigDecimal.scala
@@ -91,6 +91,24 @@ class TestBigDecimal extends QueryTest with BeforeAndAfterAll {
     checkAnswer(sql("select count(distinct salary) from carbonTable"),
       sql("select count(distinct salary) from hiveTable"))
   }
+  test("test filter query on big decimal column") {
+    // equal to
+    checkAnswer(sql("select salary from carbonTable where salary=45234525465882.24"),
+      sql("select salary from hiveTable where salary=45234525465882.24"))
+    // greater than
+    checkAnswer(sql("select salary from carbonTable where salary>15000"),
+      sql("select salary from hiveTable where salary>15000"))
+    // greater than equal to
+    checkAnswer(sql("select salary from carbonTable where salary>=15000.43525"),
+      sql("select salary from hiveTable where salary>=15000.43525"))
+    // less than
+    checkAnswer(sql("select salary from carbonTable where salary<45234525465882"),
+      sql("select salary from hiveTable where salary<45234525465882"))
+    // less than equal to
+    checkAnswer(sql("select salary from carbonTable where salary<=45234525465882.24"),
+      sql("select salary from hiveTable where salary<=45234525465882.24"))
+  }
+  
 
   override def afterAll {
     sql("drop table if exists carbonTable")


Mime
View raw message