carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [39/50] [abbrv] carbondata git commit: [CARBONDATA-2030]avg with Aggregate table for double data type is failed.
Date Sun, 28 Jan 2018 06:46:08 GMT
[CARBONDATA-2030]avg with Aggregate table for double data type is failed.

for avg column , agg table returns sum and count , sum col. data type is based on actual data
type of the column but for count col. always LongType .so while doing divide by it is failed
in spark layer.Change the return datatype for count also . use the same datatype sum column

This closes #1807


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

Branch: refs/heads/fgdatamap
Commit: ff10bbb05a9039e46c2200eecb86a39e598b8559
Parents: 29c9855
Author: BJangir <babulaljangir111@gmail.com>
Authored: Mon Jan 15 22:35:54 2018 +0530
Committer: kumarvishal <kumarvishal.1802@gmail.com>
Committed: Wed Jan 17 23:51:25 2018 +0530

----------------------------------------------------------------------
 .../preaggregate/TestPreAggregateLoad.scala     | 46 ++++++++++++++++++++
 .../preaaggregate/PreAggregateUtil.scala        |  4 +-
 2 files changed, 48 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/ff10bbb0/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateLoad.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateLoad.scala
b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateLoad.scala
index 3d0e9b9..0601099 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateLoad.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateLoad.scala
@@ -262,5 +262,51 @@ class TestPreAggregateLoad extends QueryTest with BeforeAndAfterAll {
         .stripMargin)
     checkAnswer(sql("select * from maintable_preagg_sum"), Row(1, 52, "xyz"))
   }
+test("check load and select for avg double datatype") {
+  sql("drop table if exists maintbl ")
+  sql("create table maintbl(year int,month int,name string,salary double) stored by 'carbondata'
tblproperties('sort_scope'='Global_sort','table_blocksize'='23','sort_columns'='month,year,name')")
+  sql("insert into maintbl select 10,11,'babu',12.89")
+  sql("insert into maintbl select 10,11,'babu',12.89")
+  sql("create datamap maintbl_douoble on table maintbl using 'preaggregate' as select name,avg(salary)
from maintbl group by name")
+  checkAnswer(sql("select name,avg(salary) from maintbl group by name"), Row("babu", 12.89))
+}
+
+
+  test("check load and select for avg int datatype") {
+    sql("drop table if exists maintbl ")
+    sql("create table maintbl(year int,month int,name string,salary int) stored by 'carbondata'
tblproperties('sort_scope'='Global_sort','table_blocksize'='23','sort_columns'='month,year,name')")
+    sql("insert into maintbl select 10,11,'babu',12")
+    sql("insert into maintbl select 10,11,'babu',12")
+    sql("create datamap maintbl_douoble on table maintbl using 'preaggregate' as select name,avg(salary)
from maintbl group by name")
+    checkAnswer(sql("select name,avg(salary) from maintbl group by name"), Row("babu", 12.0))
+  }
+
+  test("check load and select for avg bigint datatype") {
+    sql("drop table if exists maintbl ")
+    sql("create table maintbl(year int,month int,name string,salary bigint) stored by 'carbondata'
tblproperties('sort_scope'='Global_sort','table_blocksize'='23','sort_columns'='month,year,name')")
+    sql("insert into maintbl select 10,11,'babu',12")
+    sql("insert into maintbl select 10,11,'babu',12")
+    sql("create datamap maintbl_douoble on table maintbl using 'preaggregate' as select name,avg(salary)
from maintbl group by name")
+    checkAnswer(sql("select name,avg(salary) from maintbl group by name"), Row("babu", 12.0))
+  }
+
+  test("check load and select for avg short datatype") {
+    sql("drop table if exists maintbl ")
+    sql("create table maintbl(year int,month int,name string,salary short) stored by 'carbondata'
tblproperties('sort_scope'='Global_sort','table_blocksize'='23','sort_columns'='month,year,name')")
+    sql("insert into maintbl select 10,11,'babu',12")
+    sql("insert into maintbl select 10,11,'babu',12")
+    sql("create datamap maintbl_douoble on table maintbl using 'preaggregate' as select name,avg(salary)
from maintbl group by name")
+    checkAnswer(sql("select name,avg(salary) from maintbl group by name"), Row("babu", 12.0))
+  }
+
+  test("check load and select for avg float datatype") {
+    sql("drop table if exists maintbl ")
+    sql("create table maintbl(year int,month int,name string,salary float) stored by 'carbondata'
tblproperties('sort_scope'='Global_sort','table_blocksize'='23','sort_columns'='month,year,name')")
+    sql("insert into maintbl select 10,11,'babu',12")
+    sql("insert into maintbl select 10,11,'babu',12")
+    sql("create datamap maintbl_douoble on table maintbl using 'preaggregate' as select name,avg(salary)
from maintbl group by name")
+    checkAnswer(sql("select name,avg(salary) from maintbl group by name"), Row("babu", 12.89))
+  }
+
 
 }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/ff10bbb0/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/preaaggregate/PreAggregateUtil.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/preaaggregate/PreAggregateUtil.scala
b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/preaaggregate/PreAggregateUtil.scala
index 7f1f46f..d77f2c2 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/preaaggregate/PreAggregateUtil.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/preaaggregate/PreAggregateUtil.scala
@@ -289,7 +289,7 @@ object PreAggregateUtil {
           "sum")
         list += createFieldForAggregateExpression(
           exp,
-          LongType,
+          changeDataType,
           carbonTable,
           newColumnName,
           "count")
@@ -302,7 +302,7 @@ object PreAggregateUtil {
           "sum")
         list += createFieldForAggregateExpression(
           exp,
-          LongType,
+          avg.dataType,
           carbonTable,
           newColumnName,
           "count")


Mime
View raw message