Skip to content

Commit

Permalink
Gets table names directly from Hive tables
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGekk committed Aug 5, 2020
1 parent 1b6f482 commit 9236cc6
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -759,15 +759,17 @@ private[hive] class HiveClientImpl(
dbName: String,
pattern: String,
tableType: CatalogTableType): Seq[String] = withHiveState {
val hiveTableType = toHiveTableType(tableType)
try {
// Try with Hive API getTablesByType first, it's supported from Hive 2.3+.
shim.getTablesByType(client, dbName, pattern, toHiveTableType(tableType))
shim.getTablesByType(client, dbName, pattern, hiveTableType)
} catch {
case _: UnsupportedOperationException =>
// Fallback to filter logic if getTablesByType not supported.
val tableNames = client.getTablesByPattern(dbName, pattern).asScala
val tables = getTablesByName(dbName, tableNames.toSeq).filter(_.tableType == tableType)
tables.map(_.identifier.table)
getRawTablesByName(dbName, tableNames)
.filter(_.getTableType == hiveTableType)
.map(_.getTableName)
}
}

Expand Down

0 comments on commit 9236cc6

Please sign in to comment.