carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [16/25] carbondata git commit: [CARBONDATA-2208]Pre aggregate datamap creation is failing when count(*) present in query
Date Sat, 03 Mar 2018 12:44:03 GMT
[CARBONDATA-2208]Pre aggregate datamap creation is failing when count(*) present in query

create datamap agg on table maintable using 'preaggregate' as select name, count(*) from maintable
group by name

This closes #2004


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

Branch: refs/heads/branch-1.3
Commit: bbe73767887dabf9886dcaa8849ebac9256da6c5
Parents: 566217c
Author: kumarvishal <kumarvishal.1802@gmail.com>
Authored: Tue Feb 27 16:01:06 2018 +0530
Committer: ravipesala <ravi.pesala@gmail.com>
Committed: Sat Mar 3 18:03:27 2018 +0530

----------------------------------------------------------------------
 .../apache/carbondata/core/util/path/CarbonTablePath.java    | 7 ++++++-
 .../preaggregate/TestPreAggregateTableSelection.scala        | 7 +++++++
 .../execution/command/preaaggregate/PreAggregateUtil.scala   | 8 +++++---
 3 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/bbe73767/core/src/main/java/org/apache/carbondata/core/util/path/CarbonTablePath.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/util/path/CarbonTablePath.java
b/core/src/main/java/org/apache/carbondata/core/util/path/CarbonTablePath.java
index f232c23..b5fe5ea 100644
--- a/core/src/main/java/org/apache/carbondata/core/util/path/CarbonTablePath.java
+++ b/core/src/main/java/org/apache/carbondata/core/util/path/CarbonTablePath.java
@@ -75,7 +75,12 @@ public class CarbonTablePath extends Path {
    * @param carbonFilePath
    */
   public static String getFolderContainingFile(String carbonFilePath) {
-    return carbonFilePath.substring(0, carbonFilePath.lastIndexOf('/'));
+    int lastIndex = carbonFilePath.lastIndexOf('/');
+    // below code for handling windows environment
+    if (-1 == lastIndex) {
+      lastIndex = carbonFilePath.lastIndexOf(File.separator);
+    }
+    return carbonFilePath.substring(0, lastIndex);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/carbondata/blob/bbe73767/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 19d4abe..0f59949 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
@@ -49,6 +49,7 @@ 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 datamap agg9 on table maintable using 'preaggregate' as select name, count(*)
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")
@@ -66,6 +67,11 @@ class TestPreAggregateTableSelection extends QueryTest with BeforeAndAfterAll
{
     preAggTableValidator(df.queryExecution.analyzed, "maintable_agg0")
   }
 
+  test("test PreAggregate table selection with count(*)") {
+    val df = sql("select name, count(*) from mainTable group by name")
+    preAggTableValidator(df.queryExecution.analyzed, "maintable_agg9")
+  }
+
   test("test PreAggregate table selection 2") {
     val df = sql("select name from mainTable where name in (select name from mainTable) group
by name")
     preAggTableValidator(df.queryExecution.analyzed, "mainTable")
@@ -342,6 +348,7 @@ test("test PreAggregate table selection with timeseries and normal together")
{
     sql("drop table if exists lineitem")
     sql("DROP TABLE IF EXISTS maintabletime")
     sql("DROP TABLE IF EXISTS maintabledict")
+    sql("DROP TABLE IF EXISTS mainTableavg")
   }
 
 }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/bbe73767/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 0bee383..1bd12cd 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
@@ -346,11 +346,13 @@ object PreAggregateUtil {
         carbonTable)
     }
     // if parent column relation is of size more than one that means aggregate table
-    // column is derived from multiple column of main table
-    // or if expression is not a instance of attribute reference
+    // column is derived from multiple column of main table or if size is zero then it means
+    // column is present in select statement is some constants for example count(*)
+    // and if expression is not a instance of attribute reference
     // then use column name which is passed
     val columnName =
-    if (parentColumnsName.size > 1 && !expression.isInstanceOf[AttributeReference])
{
+    if ((parentColumnsName.size > 1 || parentColumnsName.isEmpty) &&
+        !expression.isInstanceOf[AttributeReference]) {
       newColumnName
     } else {
       expression.asInstanceOf[AttributeReference].name


Mime
View raw message