Skip to content

Commit aa0cf0a

Browse files
committed
code refactor.
1 parent 4872918 commit aa0cf0a

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,18 +617,18 @@ class Analyzer(
617617
private def lookupTableFromCatalog(
618618
u: UnresolvedRelation,
619619
defaultDatabase: Option[String] = None): LogicalPlan = {
620-
val db = u.tableIdentifier.database.orElse(defaultDatabase)
621-
val tableIdentWithDb = u.tableIdentifier.copy(database = db)
620+
val tableIdentWithDb = u.tableIdentifier.copy(database = u.tableIdentifier.database
621+
.orElse(defaultDatabase))
622622
try {
623623
catalog.lookupRelation(tableIdentWithDb, u.alias)
624624
} catch {
625625
case _: NoSuchTableException =>
626626
u.failAnalysis(s"Table or view not found: ${tableIdentWithDb.unquotedString}")
627627
// If the database is defined and that database is not found, throw an AnalysisException.
628628
// Note that if the database is not defined, it is possible we are looking up a temp view.
629-
case _: NoSuchDatabaseException if db.isDefined =>
629+
case e: NoSuchDatabaseException =>
630630
u.failAnalysis(s"Table or view not found: ${tableIdentWithDb.unquotedString}, the " +
631-
s"database ${db.get} doesn't exsits.")
631+
s"database ${e.db} doesn't exsits.")
632632
}
633633
}
634634

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/NoSuchItemException.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import org.apache.spark.sql.catalyst.catalog.CatalogTypes.TablePartitionSpec
2525
* Thrown by a catalog when an item cannot be found. The analyzer will rethrow the exception
2626
* as an [[org.apache.spark.sql.AnalysisException]] with the correct position information.
2727
*/
28-
class NoSuchDatabaseException(db: String) extends AnalysisException(s"Database '$db' not found")
28+
class NoSuchDatabaseException(val db: String) extends AnalysisException(s"Database '$db' not found")
2929

3030
class NoSuchTableException(db: String, table: String)
3131
extends AnalysisException(s"Table or view '$table' not found in database '$db'")

sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import org.apache.spark.sql.catalyst.TableIdentifier
2222
import org.apache.spark.sql.catalyst.analysis.NoSuchTableException
2323
import org.apache.spark.sql.test.{SharedSQLContext, SQLTestUtils}
2424

25-
class SimpleSQLViewSuite extends SQLViewSuite with SharedSQLContext {
26-
}
25+
class SimpleSQLViewSuite extends SQLViewSuite with SharedSQLContext
2726

2827
/**
2928
* A suite for testing view related functionality.

0 commit comments

Comments
 (0)