carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [06/50] carbondata git commit: [CARBONDATA-2534][MV] Fix substring expression not working in MV creation
Date Mon, 30 Jul 2018 18:42:32 GMT
[CARBONDATA-2534][MV] Fix substring expression not working in MV creation

Problem: The column generated when subquery expression column present is wrong while creating
of MV table.
Solution: Corrected the column name by removing special characters.

This closes #2476


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

Branch: refs/heads/branch-1.4
Commit: 5e22e9e8bd9052e3f67bee87832059acf4edc1c7
Parents: 5cc9188
Author: ravipesala <ravi.pesala@gmail.com>
Authored: Sun Jul 15 17:42:59 2018 +0530
Committer: ravipesala <ravi.pesala@gmail.com>
Committed: Tue Jul 31 00:10:41 2018 +0530

----------------------------------------------------------------------
 .../org/apache/carbondata/mv/datamap/MVHelper.scala     |  7 ++++++-
 .../apache/carbondata/mv/rewrite/MVCreateTestCase.scala | 12 ++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/5e22e9e8/datamap/mv/core/src/main/scala/org/apache/carbondata/mv/datamap/MVHelper.scala
----------------------------------------------------------------------
diff --git a/datamap/mv/core/src/main/scala/org/apache/carbondata/mv/datamap/MVHelper.scala
b/datamap/mv/core/src/main/scala/org/apache/carbondata/mv/datamap/MVHelper.scala
index fe761c0..8f79d64 100644
--- a/datamap/mv/core/src/main/scala/org/apache/carbondata/mv/datamap/MVHelper.scala
+++ b/datamap/mv/core/src/main/scala/org/apache/carbondata/mv/datamap/MVHelper.scala
@@ -119,7 +119,12 @@ object MVHelper {
   }
 
   def updateColumnName(attr: Attribute): String = {
-    val name = attr.name.replace("(", "_").replace(")", "").replace(" ", "_").replace("=",
"")
+    val name =
+      attr.name.replace("(", "_")
+        .replace(")", "")
+        .replace(" ", "_")
+        .replace("=", "")
+        .replace(",", "")
     attr.qualifier.map(qualifier => qualifier + "_" + name).getOrElse(name)
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/5e22e9e8/datamap/mv/core/src/test/scala/org/apache/carbondata/mv/rewrite/MVCreateTestCase.scala
----------------------------------------------------------------------
diff --git a/datamap/mv/core/src/test/scala/org/apache/carbondata/mv/rewrite/MVCreateTestCase.scala
b/datamap/mv/core/src/test/scala/org/apache/carbondata/mv/rewrite/MVCreateTestCase.scala
index 4056f92..7ac3c83 100644
--- a/datamap/mv/core/src/test/scala/org/apache/carbondata/mv/rewrite/MVCreateTestCase.scala
+++ b/datamap/mv/core/src/test/scala/org/apache/carbondata/mv/rewrite/MVCreateTestCase.scala
@@ -750,6 +750,18 @@ class MVCreateTestCase extends QueryTest with BeforeAndAfterAll {
     sql("drop table if exists test1")
   }
 
+  test("jira carbondata-2534") {
+
+    sql("drop datamap if exists MV_exp")
+    sql("create datamap MV_exp using 'mv' as select sum(salary),substring(empname,2,5),designation
from fact_table1 group by substring(empname,2,5),designation")
+    sql("rebuild datamap MV_exp")
+    val frame = sql(
+      "select sum(salary),substring(empname,2,5),designation from fact_table1 group by substring(empname,2,5),designation")
+    val analyzed = frame.queryExecution.analyzed
+    assert(verifyMVDataMap(analyzed, "MV_exp"))
+    sql("drop datamap if exists MV_exp")
+  }
+
   def verifyMVDataMap(logicalPlan: LogicalPlan, dataMapName: String): Boolean = {
     val tables = logicalPlan collect {
       case l: LogicalRelation => l.catalogTable.get


Mime
View raw message