Skip to content

Commit

Permalink
Merge 94edb0d into 9ee0f35
Browse files Browse the repository at this point in the history
  • Loading branch information
Sssan520 committed Aug 16, 2018
2 parents 9ee0f35 + 94edb0d commit e5008c8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
Expand Up @@ -129,6 +129,38 @@ class TestPreAggregateDrop extends QueryTest with BeforeAndAfterAll {
assert(e.getMessage.contains("Table or view 'maintable' not found in"))
}

test("drop preaggregate datamap which its main table has other type datamaps") {
sql("drop table if exists maintable")
sql("create table maintable (a string, b string, c string) stored by 'carbondata'")
sql(
"create datamap bloom1 on table maintable using 'bloomfilter'" +
" dmproperties('index_columns'='a')")
sql(
"create datamap preagg1 on table maintable using 'preaggregate' as select" +
" a,sum(b) from maintable group by a")
sql("drop datamap if exists bloom1 on table maintable")
sql("drop datamap if exists preagg1 on table maintable")
checkExistence(sql("SHOW DATAMAP ON TABLE maintable"), false, "maintable_preagg1")
sql(
"create datamap bloom1 on table maintable using 'bloomfilter'" +
" dmproperties('index_columns'='a')")
sql(
"create datamap preagg1 on table maintable using 'preaggregate' as select" +
" a,sum(b) from maintable group by a")
sql("drop datamap if exists preagg1 on table maintable")
sql("drop datamap if exists bloom1 on table maintable")
checkExistence(sql("SHOW DATAMAP ON TABLE maintable"), false, "maintable_preagg1")
sql(
"create datamap bloom1 on table maintable using 'bloomfilter'" +
" dmproperties('index_columns'='a')")
sql(
"create datamap preagg1 on table maintable using 'preaggregate' as select" +
" a,sum(b) from maintable group by a")
sql("drop table if exists maintable")
checkExistence(sql("show tables"), false, "maintable_preagg1", "maintable")
checkExistence(sql("show datamap"), false, "bloom1")
}

override def afterAll() {
sql("drop table if exists maintable")
sql("drop table if exists maintable1")
Expand Down
Expand Up @@ -116,8 +116,12 @@ case class CarbonDropDataMapCommand(
// drop index datamap on the main table
if (mainTable != null &&
DataMapStoreManager.getInstance().getAllDataMap(mainTable).size() > 0) {
dropDataMapFromSystemFolder(sparkSession)
return Seq.empty
val dmSchemaOp = DataMapStoreManager.getInstance().getAllDataMap(mainTable).asScala.
find(_.getDataMapSchema.getDataMapName.equalsIgnoreCase(dataMapName))
if (dmSchemaOp.isDefined) {
dropDataMapFromSystemFolder(sparkSession)
return Seq.empty
}
}

// If datamap to be dropped in parent table then drop the datamap from metastore and remove
Expand Down Expand Up @@ -160,9 +164,8 @@ case class CarbonDropDataMapCommand(
} else if (!ifExistsSet) {
throw new NoSuchDataMapException(dataMapName, tableName)
}
} else if (mainTable != null &&
mainTable.getTableInfo.getDataMapSchemaList.size() == 0) {
dropDataMapFromSystemFolder(sparkSession)
} else if (!ifExistsSet) {
throw new NoSuchDataMapException(dataMapName)
}
} catch {
case e: NoSuchDataMapException =>
Expand Down Expand Up @@ -191,7 +194,7 @@ case class CarbonDropDataMapCommand(
}
}

Seq.empty
Seq.empty
}

private def dropDataMapFromSystemFolder(sparkSession: SparkSession): Unit = {
Expand Down

0 comments on commit e5008c8

Please sign in to comment.