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 @@ -24,7 +24,7 @@ import scala.collection.JavaConverters._
import scala.collection.mutable

import org.apache.spark.sql.catalyst.{FunctionIdentifier, SQLConfHelper, TableIdentifier}
import org.apache.spark.sql.catalyst.analysis.{NoSuchTableException, TableAlreadyExistsException}
import org.apache.spark.sql.catalyst.analysis.{NoSuchDatabaseException, NoSuchTableException, TableAlreadyExistsException}
import org.apache.spark.sql.catalyst.catalog.{CatalogDatabase, CatalogTable, CatalogTableType, CatalogUtils, SessionCatalog}
import org.apache.spark.sql.connector.catalog.{CatalogManager, CatalogV2Util, FunctionCatalog, Identifier, NamespaceChange, SupportsNamespaces, Table, TableCatalog, TableChange, V1Table}
import org.apache.spark.sql.connector.catalog.NamespaceChange.RemoveProperty
Expand Down Expand Up @@ -245,7 +245,12 @@ class V2SessionCatalog(catalog: SessionCatalog)
override def loadNamespaceMetadata(namespace: Array[String]): util.Map[String, String] = {
namespace match {
case Array(db) =>
catalog.getDatabaseMetadata(db).toMetadata
try {
catalog.getDatabaseMetadata(db).toMetadata
} catch {
case _: NoSuchDatabaseException =>
throw QueryCompilationErrors.noSuchNamespaceError(namespace)
}

case _ =>
throw QueryCompilationErrors.noSuchNamespaceError(namespace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ trait DescribeNamespaceSuiteBase extends command.DescribeNamespaceSuiteBase
* table catalog.
*/
class DescribeNamespaceSuite extends DescribeNamespaceSuiteBase with CommandSuiteBase {
override def notFoundMsgPrefix: String = if (conf.useV1Command) "Database" else "Namespace"
override def commandVersion: String = super[DescribeNamespaceSuiteBase].commandVersion
}
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ class V2SessionCatalogNamespaceSuite extends V2SessionCatalogBaseSuite {
test("loadNamespaceMetadata: fail missing namespace") {
val catalog = newCatalog()

val exc = intercept[NoSuchDatabaseException] {
val exc = intercept[NoSuchNamespaceException] {
catalog.loadNamespaceMetadata(testNs)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ import org.apache.spark.sql.execution.command.v1
* table catalog.
*/
class DescribeNamespaceSuite extends v1.DescribeNamespaceSuiteBase with CommandSuiteBase {
override def notFoundMsgPrefix: String = if (conf.useV1Command) "Database" else "Namespace"
override def commandVersion: String = super[DescribeNamespaceSuiteBase].commandVersion
}