Skip to content

Commit

Permalink
Just protect client.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhuai committed Apr 2, 2015
1 parent 424e987 commit 5416b0f
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,16 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with

def lookupRelation(
tableIdentifier: Seq[String],
alias: Option[String]): LogicalPlan = synchronized {
alias: Option[String]): LogicalPlan = {
val tableIdent = processTableIdentifier(tableIdentifier)
val databaseName = tableIdent.lift(tableIdent.size - 2).getOrElse(
hive.sessionState.getCurrentDatabase)
val tblName = tableIdent.last
val table = try client.getTable(databaseName, tblName) catch {
val table = try {
synchronized {
client.getTable(databaseName, tblName)
}
} catch {
case te: org.apache.hadoop.hive.ql.metadata.InvalidTableException =>
throw new NoSuchTableException
}
Expand All @@ -200,7 +204,9 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with
} else {
val partitions: Seq[Partition] =
if (table.isPartitioned) {
HiveShim.getAllPartitionsOf(client, table).toSeq
synchronized {
HiveShim.getAllPartitionsOf(client, table).toSeq
}
} else {
Nil
}
Expand Down

0 comments on commit 5416b0f

Please sign in to comment.