Skip to content

Commit

Permalink
Fixed count(*) issue when MV is created with simple projection.
Browse files Browse the repository at this point in the history
  • Loading branch information
ravipesala committed May 21, 2019
1 parent 4d7c8ad commit 7b66f81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -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 &&
Expand Down
Expand Up @@ -1019,6 +1019,17 @@ class MVCreateTestCase extends QueryTest with BeforeAndAfterAll {
sql("drop table if exists all_table")
}

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")
checkAnswer(sql("select count(*) from mvtable1"),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
Expand Down

0 comments on commit 7b66f81

Please sign in to comment.