Skip to content

Commit 71d9ad1

Browse files
committed
Use tableExists in check for new table name
1 parent e95c603 commit 71d9ad1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2SessionCatalog.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,8 @@ class V2SessionCatalog(sessionState: SessionState) extends TableCatalog {
154154
}
155155

156156
override def renameTable(oldIdent: Identifier, newIdent: Identifier): Unit = {
157-
try {
158-
if (Option(loadTable(newIdent)).isDefined) throw new TableAlreadyExistsException(newIdent)
159-
} catch {
160-
case _: NoSuchTableException =>
157+
if (tableExists(newIdent)) {
158+
throw new TableAlreadyExistsException(newIdent)
161159
}
162160

163161
// Load table to make sure the table exists

0 commit comments

Comments
 (0)