Skip to content

Commit a845488

Browse files
committed
revert previous changes
1 parent 517793f commit a845488

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,6 @@ class Analyzer(
793793
* [[ResolveRelations]] still resolves v1 tables.
794794
*/
795795
object ResolveTables extends Rule[LogicalPlan] {
796-
import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
797-
798796
def apply(plan: LogicalPlan): LogicalPlan = ResolveTempViews(plan).resolveOperatorsUp {
799797
case u: UnresolvedRelation =>
800798
lookupV2Relation(u.multipartIdentifier)
@@ -811,23 +809,12 @@ class Analyzer(
811809
.getOrElse(i)
812810

813811
case alter @ AlterTable(_, _, u: UnresolvedV2Relation, _) =>
814-
resolveV2Relation(u).map(rel => alter.copy(table = rel)).getOrElse(alter)
812+
CatalogV2Util.loadRelation(u.catalog, u.tableName)
813+
.map(rel => alter.copy(table = rel))
814+
.getOrElse(alter)
815815

816816
case u: UnresolvedV2Relation =>
817-
resolveV2Relation(u).getOrElse(u)
818-
}
819-
820-
private def resolveV2Relation(unresolved: UnresolvedV2Relation) : Option[NamedRelation] = {
821-
val maybeTempView = unresolved.originalNameParts match {
822-
case Seq(part) => v1SessionCatalog.lookupTempView(part)
823-
case _ => None
824-
}
825-
if (maybeTempView.isDefined) {
826-
unresolved.failAnalysis(
827-
s"Invalid command: '${unresolved.originalNameParts.quoted}' is a view not a table.")
828-
}
829-
830-
CatalogV2Util.loadRelation(unresolved.catalog, unresolved.tableName)
817+
CatalogV2Util.loadRelation(u.catalog, u.tableName).getOrElse(u)
831818
}
832819

833820
/**

sql/core/src/test/scala/org/apache/spark/sql/connector/TableResolutionSuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class TableResolutionSuite extends QueryTest with SharedSparkSession with Before
3838
val tbl = "t"
3939
val commands = Seq(
4040
s"DESCRIBE $tbl",
41-
s"SHOW TBLPROPERTIES $tbl",
42-
s"ALTER TABLE $tbl ADD COLUMN data string"
41+
s"SHOW TBLPROPERTIES $tbl"
42+
// s"ALTER TABLE $tbl ADD COLUMN data string"
4343
)
4444

4545
withTempView(s"$tbl") {
@@ -52,7 +52,7 @@ class TableResolutionSuite extends QueryTest with SharedSparkSession with Before
5252
val ex = intercept[AnalysisException] {
5353
sql(command)
5454
}
55-
assert(ex.getMessage.contains(s"Invalid command: '$tbl' is a view not a table."))
55+
assert(ex.getMessage.contains(s"$tbl is a temp view not table."))
5656
}
5757
}
5858
}

0 commit comments

Comments
 (0)