From 95e56a2de71505a26674b5c4ee4eea2d30ea01da Mon Sep 17 00:00:00 2001 From: Geetika Gupta Date: Fri, 2 Feb 2018 14:02:38 +0530 Subject: [PATCH] 1. Refactored code to get child column by parent column name for select operation in datamap 2. Added related test case --- .../schema/table/AggregationDataMapSchema.java | 3 ++- .../testsuite/preaggregate/TestPreAggregateLoad.scala | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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 e06181226f0..2a16e1f858a 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 ColumnSchema getChildColByParentColName(String columName) { List 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; } } 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 b6b7a171d70..da1ffb5b4d3 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) + } + }