carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject carbondata git commit: [CARBONDATA-2542][MV] Fix the mv query from table with different database
Date Tue, 24 Jul 2018 00:52:20 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master 2c291d620 -> d820e3d51


[CARBONDATA-2542][MV] Fix the mv query from table with different database

Problem: database name is not added to the table name while generating mv query.
Solution: Add the database name to the table name while creating mv query.

This closes #2479


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

Branch: refs/heads/master
Commit: d820e3d5186afd07066b7ffb12db7446aa934f22
Parents: 2c291d6
Author: ravipesala <ravi.pesala@gmail.com>
Authored: Sun Jul 15 17:38:47 2018 +0530
Committer: Jacky Li <jacky.likun@qq.com>
Committed: Tue Jul 24 08:50:48 2018 +0800

----------------------------------------------------------------------
 .../mv/rewrite/MVCreateTestCase.scala           | 23 +++++++++++++++++++-
 .../carbondata/mv/plans/util/Printers.scala     |  2 +-
 2 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/d820e3d5/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 7ac3c83..264eb96 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
@@ -762,6 +762,28 @@ class MVCreateTestCase extends QueryTest with BeforeAndAfterAll {
     sql("drop datamap if exists MV_exp")
   }
 
+  test("jira carbondata-2542") {
+    sql("""drop database if exists xy cascade""")
+    sql("""create database if not exists xy""")
+    sql(
+      """
+        | CREATE TABLE xy.fact_tablexy (empname String, designation String, doj Timestamp,
+        |  workgroupcategory int, workgroupcategoryname String, deptno int, deptname String,
+        |  projectcode int, projectjoindate Timestamp, projectenddate Timestamp,attendance
int,
+        |  utilization int,salary int)
+        | STORED BY 'org.apache.carbondata.format'
+      """.stripMargin)
+    sql("drop datamap if exists MV_exp")
+    sql("create datamap MV_exp using 'mv' as select doj,sum(salary) from xy.fact_tablexy
group by doj")
+    sql("rebuild datamap MV_exp")
+    val frame = sql(
+      "select doj,sum(salary) from xy.fact_tablexy group by doj")
+    val analyzed = frame.queryExecution.analyzed
+    assert(verifyMVDataMap(analyzed, "MV_exp"))
+    sql("drop datamap if exists MV_exp")
+    sql("""drop database if exists xy cascade""")
+  }
+
   def verifyMVDataMap(logicalPlan: LogicalPlan, dataMapName: String): Boolean = {
     val tables = logicalPlan collect {
       case l: LogicalRelation => l.catalogTable.get
@@ -769,7 +791,6 @@ class MVCreateTestCase extends QueryTest with BeforeAndAfterAll {
     tables.exists(_.identifier.table.equalsIgnoreCase(dataMapName+"_table"))
   }
 
-
   def drop(): Unit = {
     sql("drop table IF EXISTS fact_table1")
     sql("drop table IF EXISTS fact_table2")

http://git-wip-us.apache.org/repos/asf/carbondata/blob/d820e3d5/datamap/mv/plan/src/main/scala/org/apache/carbondata/mv/plans/util/Printers.scala
----------------------------------------------------------------------
diff --git a/datamap/mv/plan/src/main/scala/org/apache/carbondata/mv/plans/util/Printers.scala
b/datamap/mv/plan/src/main/scala/org/apache/carbondata/mv/plans/util/Printers.scala
index b7641d5..d3ce38d 100644
--- a/datamap/mv/plan/src/main/scala/org/apache/carbondata/mv/plans/util/Printers.scala
+++ b/datamap/mv/plan/src/main/scala/org/apache/carbondata/mv/plans/util/Printers.scala
@@ -180,7 +180,7 @@ trait Printers {
     }
 
     def printTable(name: Seq[String]): Unit = {
-      print("%s".format(name.last))
+      print("%s".format(name.mkString(".")))
     }
 
     trait ExprSeq extends Seq[SortOrder]


Mime
View raw message