You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ku...@apache.org on 2019/06/14 09:50:23 UTC
[carbondata] branch master updated: [HOTFIX] Fixed count(*) issue
when MV is created with simple projection
This is an automated email from the ASF dual-hosted git repository.
kunalkapoor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/carbondata.git
The following commit(s) were added to refs/heads/master by this push:
new 14f170c [HOTFIX] Fixed count(*) issue when MV is created with simple projection
14f170c is described below
commit 14f170c5daf32febc536444ce441f8ba0d0fa143
Author: ravipesala <ra...@gmail.com>
AuthorDate: Tue May 21 17:40:56 2019 +0530
[HOTFIX] Fixed count(*) issue when MV is created with simple projection
Problem:
When MV is created with simple projection and select count(*) is fired
on main table then it is wrongly taking MV table with wrong projections.
Solution:
Simple projection MV should not be selected when count(*) is fired.
This closed #3229
---
.../apache/carbondata/mv/rewrite/DefaultMatchMaker.scala | 4 +++-
.../org/apache/carbondata/mv/rewrite/MVCreateTestCase.scala | 13 +++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/datamap/mv/core/src/main/scala/org/apache/carbondata/mv/rewrite/DefaultMatchMaker.scala b/datamap/mv/core/src/main/scala/org/apache/carbondata/mv/rewrite/DefaultMatchMaker.scala
index 59d72f8..bd412e7 100644
--- a/datamap/mv/core/src/main/scala/org/apache/carbondata/mv/rewrite/DefaultMatchMaker.scala
+++ b/datamap/mv/core/src/main/scala/org/apache/carbondata/mv/rewrite/DefaultMatchMaker.scala
@@ -179,7 +179,9 @@ object SelectSelectNoChildDelta extends DefaultMatchPattern with PredicateHelper
sel_1q.predicateList.exists(_.semanticEquals(expr)))
val isPredicateEmdR = sel_1q.predicateList.forall(expr =>
isDerivable(expr, sel_1a.outputList ++ rejoinOutputList, sel_1q, sel_1a, None))
- val isOutputEdR = sel_1q.outputList.forall(expr =>
+ // Check if sel_1q.outputList is non empty and then check whether
+ // it can be derivable with sel_1a otherwise for empty cases it returns true.
+ val isOutputEdR = sel_1q.outputList.nonEmpty && sel_1q.outputList.forall(expr =>
isDerivable(expr, sel_1a.outputList ++ rejoinOutputList, sel_1q, sel_1a, None))
if (isUniqueRmE.isEmpty && isUniqueEmR.isEmpty && extrajoin.isEmpty && isPredicateRmE &&
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 e025623..a8abdc3 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
@@ -1061,6 +1061,19 @@ class MVCreateTestCase extends QueryTest with BeforeAndAfterAll {
assert(TestUtil.verifyMVDataMap(analyzed3, "single_mv"))
}
+ test("count test case") {
+
+ sql("drop table if exists mvtable1")
+ sql("create table mvtable1(name string,age int,salary int) stored by 'carbondata'")
+ sql("create datamap MV11 using 'mv' as select name from mvtable1")
+ sql("insert into mvtable1 select 'n1',12,12")
+ sql("rebuild datamap MV11")
+ val frame = sql("select count(*) from mvtable1")
+ assert(!TestUtil.verifyMVDataMap(frame.queryExecution.analyzed, "MV11"))
+ checkAnswer(frame,Seq(Row(1)))
+ sql("drop table if exists mvtable1")
+ }
+
def verifyMVDataMap(logicalPlan: LogicalPlan, dataMapName: String): Boolean = {
val tables = logicalPlan collect {
case l: LogicalRelation => l.catalogTable.get