Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1443#discussion_r150170785
--- Diff:
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/CarbonDropTableCommand.scala
---
@@ -60,33 +62,40 @@ case class CarbonDropTableCommand(
lock => carbonLocks +=
CarbonLockUtil.getLockObject(carbonTableIdentifier, lock)
}
LOGGER.audit(s"Deleting table [$tableName] under database [$dbName]")
-
- // fires the event before dropping main table
- val carbonTable = CarbonMetadata.getInstance.getCarbonTable(dbName +
"_" + tableName)
+ val carbonTable: Option[CarbonTable] = try {
+ Some(catalog.lookupRelation(identifier)(sparkSession)
+ .asInstanceOf[CarbonRelation].metaData.carbonTable)
+ } catch {
+ case ex: NoSuchTableException =>
+ if (!ifExistsSet) {
+ throw ex
+ }
+ None
+ }
val operationContext = new OperationContext
val dropTablePreEvent: DropTablePreEvent =
DropTablePreEvent(
- carbonTable,
+ carbonTable.get,
--- End diff --
you should not call get directly as in above catch there is chance of `None`
---