You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ra...@apache.org on 2018/02/03 19:43:43 UTC

[36/50] [abbrv] carbondata git commit: [CARBONDATA-2112] Fixed bug for select operation on datamap with avg and a column name

[CARBONDATA-2112] Fixed bug for select operation on datamap with avg and a column name

Problem: When applying select operation(having a column name and an aggregate function) on a
table having a datamap, the data was coming out to be wrong as the group by expression
and aggregate expression were created incorrectly.

Solution: While creating the aggregate and group by expression, we were getting the child
column related to parent column name which was coming out to be wrong so added a new
check there to get the correct child column.

This closes #1910


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

Branch: refs/heads/branch-1.3
Commit: 91911af231583b9e2b210dd685770836b358bcd0
Parents: 44e70d0
Author: Geetika Gupta <ge...@knoldus.in>
Authored: Fri Feb 2 14:02:38 2018 +0530
Committer: kunal642 <ku...@gmail.com>
Committed: Sat Feb 3 16:25:30 2018 +0530

----------------------------------------------------------------------
 .../metadata/schema/table/AggregationDataMapSchema.java  |  3 ++-
 .../testsuite/preaggregate/TestPreAggregateLoad.scala    | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/91911af2/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/AggregationDataMapSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/AggregationDataMapSchema.java b/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/AggregationDataMapSchema.java
index e061812..2a16e1f 100644
--- a/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/AggregationDataMapSchema.java
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/AggregationDataMapSchema.java
@@ -151,7 +151,8 @@ public class AggregationDataMapSchema extends DataMapSchema {
       List<ParentColumnTableRelation> parentColumnTableRelations =
           columnSchema.getParentColumnTableRelations();
       if (null != parentColumnTableRelations && parentColumnTableRelations.size() == 1
-          && parentColumnTableRelations.get(0).getColumnName().equals(columName)) {
+          && parentColumnTableRelations.get(0).getColumnName().equals(columName) &&
+          columnSchema.getColumnName().endsWith(columName)) {
         return columnSchema;
       }
     }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/91911af2/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 b6b7a17..da1ffb5 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
@@ -405,4 +405,15 @@ test("check load and select for avg double datatype") {
     sql("drop table if exists maintable")
   }
 
+  test("check load and select for avg int datatype and group by") {
+    sql("drop table if exists maintable ")
+    sql("CREATE TABLE maintable(id int, city string, age int) stored by 'carbondata'")
+    sql(s"LOAD DATA LOCAL INPATH '$testData' into table maintable")
+    sql(s"LOAD DATA LOCAL INPATH '$testData' into table maintable")
+    sql(s"LOAD DATA LOCAL INPATH '$testData' into table maintable")
+    val rows = sql("select age,avg(age) from maintable group by age").collect()
+    sql("create datamap maintbl_douoble on table maintable using 'preaggregate' as select avg(age) from maintable group by age")
+    checkAnswer(sql("select age,avg(age) from maintable group by age"), rows)
+  }
+
 }