carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kunalkap...@apache.org
Subject carbondata git commit: [CARBONDATA-2107]Fixed query failure in case if average case
Date Thu, 01 Feb 2018 12:16:02 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master d680e9cf5 -> 19fdd4d75


[CARBONDATA-2107]Fixed query failure in case if average case

Average query is failing when data map has sum(column), average(column)

This closes #1894


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

Branch: refs/heads/master
Commit: 19fdd4d7581477557f2771909cf54a95a0b6665d
Parents: d680e9c
Author: kumarvishal <kumarvishal.1802@gmail.com>
Authored: Wed Jan 31 17:44:55 2018 +0530
Committer: kunal642 <kunalkapoor642@gmail.com>
Committed: Thu Feb 1 17:44:21 2018 +0530

----------------------------------------------------------------------
 .../preaggregate/TestPreAggregateTableSelection.scala    | 11 ++++++++++-
 .../apache/spark/sql/hive/CarbonPreAggregateRules.scala  |  8 ++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/19fdd4d7/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateTableSelection.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateTableSelection.scala
b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateTableSelection.scala
index f9ac354..5fb7b02 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateTableSelection.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggregateTableSelection.scala
@@ -29,6 +29,7 @@ class TestPreAggregateTableSelection extends QueryTest with BeforeAndAfterAll
{
 
   override def beforeAll: Unit = {
     sql("drop table if exists mainTable")
+    sql("drop table if exists mainTableavg")
     sql("drop table if exists agg0")
     sql("drop table if exists agg1")
     sql("drop table if exists agg2")
@@ -47,7 +48,10 @@ class TestPreAggregateTableSelection extends QueryTest with BeforeAndAfterAll
{
     sql("create datamap agg6 on table mainTable using 'preaggregate' as select name,min(age)
from mainTable group by name")
     sql("create datamap agg7 on table mainTable using 'preaggregate' as select name,max(age)
from mainTable group by name")
     sql("create datamap agg8 on table maintable using 'preaggregate' as select name, sum(id),
avg(id) from maintable group by name")
+    sql("CREATE TABLE mainTableavg(id int, name string, city string, age bigint) STORED BY
'org.apache.carbondata.format'")
+    sql("create datamap agg0 on table mainTableavg using 'preaggregate' as select name,sum(age),
avg(age) from mainTableavg group by name")
     sql(s"LOAD DATA LOCAL INPATH '$resourcesPath/measureinsertintotest.csv' into table mainTable")
+    sql(s"LOAD DATA LOCAL INPATH '$resourcesPath/measureinsertintotest.csv' into table mainTableavg")
   }
 
   test("test sum and avg on same column should give proper results") {
@@ -191,7 +195,6 @@ class TestPreAggregateTableSelection extends QueryTest with BeforeAndAfterAll
{
     preAggTableValidator(df.queryExecution.analyzed, "maintable")
   }
 
-
   def preAggTableValidator(plan: LogicalPlan, actualTableName: String) : Unit ={
     var isValidPlan = false
     plan.transform {
@@ -312,8 +315,14 @@ test("test PreAggregate table selection with timeseries and normal together")
{
 
     sql("select var_samp(name) from maintabletime  where name='Mikka' ")
   }
+
+  test("test PreAggregate table selection For Sum And Avg in aggregate table with bigint")
{
+    val df = sql("select avg(age) from mainTableavg")
+    preAggTableValidator(df.queryExecution.analyzed, "mainTableavg_agg0")
+  }
   override def afterAll: Unit = {
     sql("drop table if exists mainTable")
+    sql("drop table if exists mainTable_avg")
     sql("drop table if exists lineitem")
     sql("DROP TABLE IF EXISTS maintabletime")
   }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/19fdd4d7/integration/spark2/src/main/scala/org/apache/spark/sql/hive/CarbonPreAggregateRules.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/hive/CarbonPreAggregateRules.scala
b/integration/spark2/src/main/scala/org/apache/spark/sql/hive/CarbonPreAggregateRules.scala
index 79cbe05..de58805 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/hive/CarbonPreAggregateRules.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/hive/CarbonPreAggregateRules.scala
@@ -1023,10 +1023,14 @@ case class CarbonPreAggregateQueryRules(sparkSession: SparkSession)
extends Rule
       // with aggregation sum and count.
       // Then add divide(sum(column with sum), sum(column with count)).
       case Average(exp: Expression) =>
-        Divide(AggregateExpression(Sum(attrs.head),
+        Divide(AggregateExpression(Sum(Cast(
+          attrs.head,
+          DoubleType)),
           aggExp.mode,
           isDistinct = false),
-          AggregateExpression(Sum(attrs.last),
+          AggregateExpression(Sum(Cast(
+            attrs.last,
+            DoubleType)),
             aggExp.mode,
             isDistinct = false))
     }


Mime
View raw message