carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenliang...@apache.org
Subject carbondata git commit: [CARBONDATA-1660] Fixed bug related to filter of data based on decimal values in presto
Date Thu, 09 Nov 2017 11:36:10 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master d7393da98 -> f3b507cb7


[CARBONDATA-1660] Fixed bug related to filter of data based on decimal values in presto

1.Fixed bug related to filter of data based on decimal values in presto, 2.Added related test
cases.

This closes #1463


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

Branch: refs/heads/master
Commit: f3b507cb78f74e58299750ac9b1dd3c990050adb
Parents: d7393da
Author: Geetika Gupta <geetika.gupta@knoldus.in>
Authored: Fri Nov 3 13:08:50 2017 +0530
Committer: chenliang613 <chenliang613@huawei.com>
Committed: Thu Nov 9 19:35:53 2017 +0800

----------------------------------------------------------------------
 .../carbondata/presto/PrestoFilterUtil.java     | 13 +++---------
 .../presto/src/test/resources/alldatatype.csv   | 22 ++++++++++----------
 .../integrationtest/PrestoAllDataTypeTest.scala | 20 +++++++++++++++++-
 .../presto/util/CarbonDataStoreCreator.scala    | 15 ++++++++++++-
 4 files changed, 47 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/f3b507cb/integration/presto/src/main/java/org/apache/carbondata/presto/PrestoFilterUtil.java
----------------------------------------------------------------------
diff --git a/integration/presto/src/main/java/org/apache/carbondata/presto/PrestoFilterUtil.java
b/integration/presto/src/main/java/org/apache/carbondata/presto/PrestoFilterUtil.java
index b8b2032..ded4889 100644
--- a/integration/presto/src/main/java/org/apache/carbondata/presto/PrestoFilterUtil.java
+++ b/integration/presto/src/main/java/org/apache/carbondata/presto/PrestoFilterUtil.java
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import com.facebook.presto.spi.type.*;
 import org.apache.carbondata.core.metadata.datatype.DataType;
 import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.ColumnExpression;
@@ -46,16 +47,6 @@ import com.facebook.presto.spi.ColumnHandle;
 import com.facebook.presto.spi.predicate.Domain;
 import com.facebook.presto.spi.predicate.Range;
 import com.facebook.presto.spi.predicate.TupleDomain;
-import com.facebook.presto.spi.type.BigintType;
-import com.facebook.presto.spi.type.BooleanType;
-import com.facebook.presto.spi.type.DateType;
-import com.facebook.presto.spi.type.DecimalType;
-import com.facebook.presto.spi.type.DoubleType;
-import com.facebook.presto.spi.type.IntegerType;
-import com.facebook.presto.spi.type.SmallintType;
-import com.facebook.presto.spi.type.TimestampType;
-import com.facebook.presto.spi.type.Type;
-import com.facebook.presto.spi.type.VarcharType;
 import com.google.common.collect.ImmutableList;
 import io.airlift.slice.Slice;
 
@@ -260,6 +251,8 @@ public class PrestoFilterUtil {
       } else if (rawdata instanceof  Long) {
         return new BigDecimal(new BigInteger(String.valueOf(rawdata)),
             ((DecimalType) type).getScale());
+      } else if(rawdata instanceof Slice) {
+        return new BigDecimal(Decimals.decodeUnscaledValue((Slice) rawdata), ((DecimalType)
type).getScale());
       }
     } else if (type.equals(TimestampType.TIMESTAMP)) {
       return (Long)rawdata * 1000;

http://git-wip-us.apache.org/repos/asf/carbondata/blob/f3b507cb/integration/presto/src/test/resources/alldatatype.csv
----------------------------------------------------------------------
diff --git a/integration/presto/src/test/resources/alldatatype.csv b/integration/presto/src/test/resources/alldatatype.csv
index 6b0259a..ba6156e 100644
--- a/integration/presto/src/test/resources/alldatatype.csv
+++ b/integration/presto/src/test/resources/alldatatype.csv
@@ -1,11 +1,11 @@
-ID,date,country,name,phonetype,serialname,salary,bonus,dob,shortfield
-1,2015-07-23,china,anubhav,phone197,ASD69643,5000000.00,1234.444,2016-04-14 15/00/09,10
-2,2015-07-24,china,jatin,phone756,ASD42892,150010.999,1234.5555,2016-04-14 15:00:09,10
-3,2015-07-25,china,liang,phone1904,ASD37014,15002.110,600.777,2016-01-14 15:07:09,8
-4,2015-07-26,china,prince,phone2435,ASD66902,15003.00,9999.999,1992-04-14 13:00:09,4
-5,2015-07-27,china,bhavya,phone2441,ASD90633,15004.00,5000.999,2010-06-19 14:10:06,11
-6,2015-07-28,china,akash,phone294,ASD59961,15005.00,500.59,2013-07-19 12:10:08,18
-7,2015-07-29,china,sahil,phone610,ASD14875,15006.00,500.99,,2007-04-19 11:10:06,17
-8,2015-07-30,china,geetika,phone1848,ASD57308,15007.500,500.88,2008-09-21 11:10:06,10
-9,2015-07-18,china,ravindra,phone706,ASD86717,15008.00,700.999,2009-06-19 15:10:06,1
-9,2015/07/18,china,jitesh,phone706,ASD86717,15008.00,500.414,2001-08-29 13:09:03,12
+ID,date,country,name,phonetype,serialname,salary,bonus,monthlyBonus,dob,shortfield
+1,2015-07-23,china,anubhav,phone197,ASD69643,5000000.00,1234.444,12.1234,2016-04-14 15/00/09,10
+2,2015-07-24,china,jatin,phone756,ASD42892,150010.999,1234.5555,15.13,2016-04-14 15:00:09,10
+3,2015-07-25,china,liang,phone1904,ASD37014,15002.110,600.777,16.181,2016-01-14 15:07:09,8
+4,2015-07-26,china,prince,phone2435,ASD66902,15003.00,9999.999,17.3654,1992-04-14 13:00:09,4
+5,2015-07-27,china,bhavya,phone2441,ASD90633,15004.00,5000.999,12.11,2010-06-19 14:10:06,11
+6,2015-07-28,china,akash,phone294,ASD59961,15005.00,500.59,18.65,2013-07-19 12:10:08,18
+7,2015-07-29,china,sahil,phone610,ASD14875,15006.00,500.99,,19.65,2007-04-19 11:10:06,17
+8,2015-07-30,china,geetika,phone1848,ASD57308,15007.500,500.88,200.97,2008-09-21 11:10:06,10
+9,2015-07-18,china,ravindra,phone706,ASD86717,15008.00,700.999,45.25,2009-06-19 15:10:06,1
+9,2015/07/18,china,jitesh,phone706,ASD86717,15008.00,500.414,11.655,2001-08-29 13:09:03,12

http://git-wip-us.apache.org/repos/asf/carbondata/blob/f3b507cb/integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoAllDataTypeTest.scala
----------------------------------------------------------------------
diff --git a/integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoAllDataTypeTest.scala
b/integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoAllDataTypeTest.scala
index 5eb06e7..dc0472d 100644
--- a/integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoAllDataTypeTest.scala
+++ b/integration/presto/src/test/scala/org/apache/carbondata/presto/integrationtest/PrestoAllDataTypeTest.scala
@@ -403,10 +403,28 @@ class PrestoAllDataTypeTest extends FunSuiteLike with BeforeAndAfterAll
{
     assert(actualResult.equals(expectedResult))
   }
 
+  test("test longDecimal type of presto") {
+    val actualResult: List[Map[String, Any]] = PrestoServer
+      .executeQuery(
+        "SELECT ID from testdb.testtable WHERE bonus = DECIMAL '1234.5555'")
+    val expectedResult: List[Map[String, Any]] = List(Map("ID" -> 2))
+
+    assert(actualResult.equals(expectedResult))
+  }
+
+  test("test shortDecimal type of presto") {
+    val actualResult: List[Map[String, Any]] = PrestoServer
+      .executeQuery(
+        "SELECT ID from testdb.testtable WHERE monthlyBonus = 15.13")
+    val expectedResult: List[Map[String, Any]] = List(Map("ID" -> 2))
+
+    assert(actualResult.equals(expectedResult))
+  }
+
   test("test timestamp datatype using cast operator") {
     val actualResult: List[Map[String, Any]] = PrestoServer
       .executeQuery("SELECT NAME AS RESULT FROM TESTDB.TESTTABLE WHERE DOB = CAST('2016-04-14
15:00:09' AS TIMESTAMP)")
     val expectedResult: List[Map[String, Any]] = List(Map("RESULT" -> "jatin"))
     assert(actualResult.equals(expectedResult))
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/carbondata/blob/f3b507cb/integration/presto/src/test/scala/org/apache/carbondata/presto/util/CarbonDataStoreCreator.scala
----------------------------------------------------------------------
diff --git a/integration/presto/src/test/scala/org/apache/carbondata/presto/util/CarbonDataStoreCreator.scala
b/integration/presto/src/test/scala/org/apache/carbondata/presto/util/CarbonDataStoreCreator.scala
index 09cddfe..e932213 100644
--- a/integration/presto/src/test/scala/org/apache/carbondata/presto/util/CarbonDataStoreCreator.scala
+++ b/integration/presto/src/test/scala/org/apache/carbondata/presto/util/CarbonDataStoreCreator.scala
@@ -124,7 +124,7 @@ object CarbonDataStoreCreator {
         "true")
       loadModel.setMaxColumns("15")
       loadModel.setCsvHeader(
-        "ID,date,country,name,phonetype,serialname,salary,bonus,dob,shortField")
+        "ID,date,country,name,phonetype,serialname,salary,bonus,monthlyBonus,dob,shortField")
       loadModel.setCsvHeaderColumns(loadModel.getCsvHeader.split(","))
       loadModel.setTaskNo("0")
       loadModel.setSegmentId("0")
@@ -245,6 +245,19 @@ object CarbonDataStoreCreator {
     bonus.setColumnReferenceId(bonus.getColumnUniqueId)
     columnSchemas.add(bonus)
 
+    val monthlyBonus: ColumnSchema = new ColumnSchema()
+    monthlyBonus.setColumnName("monthlyBonus")
+    monthlyBonus.setColumnar(true)
+    monthlyBonus.setDataType(DataTypes.createDecimalType(18, 4))
+    monthlyBonus.setPrecision(18)
+    monthlyBonus.setScale(4)
+    monthlyBonus.setEncodingList(encodings)
+    monthlyBonus.setColumnUniqueId(UUID.randomUUID().toString)
+    monthlyBonus.setDimensionColumn(false)
+    monthlyBonus.setColumnGroup(8)
+    monthlyBonus.setColumnReferenceId(monthlyBonus.getColumnUniqueId)
+    columnSchemas.add(monthlyBonus)
+
     val dob: ColumnSchema = new ColumnSchema()
     dob.setColumnName("dob")
     dob.setColumnar(true)


Mime
View raw message