Indhumathi27 commented on a change in pull request #4071: URL: https://github.com/apache/carbondata/pull/4071#discussion_r569949324
########## File path: index/secondary-index/src/test/scala/org/apache/carbondata/spark/testsuite/secondaryindex/DropTableTest.scala ########## @@ -88,4 +94,30 @@ class DropTableTest extends QueryTest with BeforeAndAfterAll { assert(sql("show indexes on testDrop").collect().isEmpty) sql("drop table if exists testDrop") } + + test("test index drop when SI table is not deleted while main table is deleted") { + sql("drop database if exists test cascade") + sql("create database test") + sql("use test") + sql("drop table if exists testDrop") + sql("create table testDrop (a string, b string, c string) STORED AS carbondata") + sql("create index index11 on table testDrop (c) AS 'carbondata'") + sql("insert into testDrop values('ab', 'cd', 'ef')") + val indexTablePath = CarbonEnv.getCarbonTable(Some("test"), + "index11")(sqlContext.sparkSession).getTablePath + val mock: MockUp[CarbonInternalMetastore.type] = new MockUp[CarbonInternalMetastore.type]() { + @Mock + def deleteIndexSilent(carbonTableIdentifier: TableIdentifier, + storePath: String, + parentCarbonTable: CarbonTable)(sparkSession: SparkSession): Unit = { + throw new RuntimeException("An exception occurred while deleting SI table") + } + } + sql("drop table if exists testDrop") + mock.tearDown() + assert(Files.exists(Paths.get(indexTablePath))) + sql("drop table if exists testDrop") + sql("drop database if exists test cascade") Review comment: can you add drop db in finally block / or in afterALL, to make sure database is dropped in case of failure ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org