Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private[hive] class HiveClientImpl(
Option(client.getDatabase(dbName)).map { d =>
CatalogDatabase(
name = d.getName,
description = d.getDescription,
description = Option(d.getDescription).getOrElse(""),
locationUri = CatalogUtils.stringToURI(d.getLocationUri),
properties = Option(d.getParameters).map(_.asScala.toMap).orNull)
}.getOrElse(throw new NoSuchDatabaseException(dbName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,10 @@ class HiveExternalCatalogSuite extends ExternalCatalogSuite {
.filter(_.contains("Num Buckets")).head
assert(bucketString.contains("10"))
}

test("SPARK-23001: NullPointerException when running desc database") {
val catalog = newBasicCatalog()
catalog.createDatabase(newDb("dbWithNullDesc").copy(description = null), ignoreIfExists = false)
assert(catalog.getDatabase("dbWithNullDesc").description == "")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ class VersionsSuite extends SparkFunSuite with Logging {
client.createDatabase(tempDB, ignoreIfExists = true)
}

test(s"$version: createDatabase with null description") {
withTempDir { tmpDir =>
val dbWithNullDesc =
CatalogDatabase("dbWithNullDesc", description = null, tmpDir.toURI, Map())
client.createDatabase(dbWithNullDesc, ignoreIfExists = true)
assert(client.getDatabase("dbWithNullDesc").description == "")
}
}

test(s"$version: setCurrentDatabase") {
client.setCurrentDatabase("default")
}
Expand Down