Maybe use an assert?

i.e.

    val table =  SharkEnv.memoryMetadataManager.getTable(databaseName, tableName)
    assert(table.isDefined && table.get isInstanceOf ...)
    table