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 @@ -681,10 +681,20 @@ class Analyzer(
.map(v2Relation => i.copy(table = v2Relation))
.getOrElse(i)

case desc @ DescribeTable(u: UnresolvedV2Relation, _) =>
resolveV2Relation(u).map(relation => desc.copy(table = relation)).getOrElse(desc)

case alter @ AlterTable(_, _, u: UnresolvedV2Relation, _) =>
resolveV2Relation(u).map(relation => alter.copy(table = relation)).getOrElse(alter)

case u: UnresolvedV2Relation =>
CatalogV2Util.loadTable(u.catalog, u.tableName).map { table =>
DataSourceV2Relation.create(table)
}.getOrElse(u)
resolveV2Relation(u).getOrElse(u)
}

private def resolveV2Relation(u: UnresolvedV2Relation): Option[DataSourceV2Relation] = {
CatalogV2Util.loadTable(u.catalog, u.tableName).map { table =>
DataSourceV2Relation.create(table)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ trait CheckAnalysis extends PredicateHelper {
case InsertIntoStatement(u: UnresolvedRelation, _, _, _, _) =>
failAnalysis(s"Table not found: ${u.multipartIdentifier.quoted}")

case AlterTable(_, _, u: UnresolvedV2Relation, _) if isView(u.originalNameParts) =>
u.failAnalysis(
s"Invalid command: '${u.originalNameParts.quoted}' is a view not a table.")

case AlterTable(_, _, u: UnresolvedV2Relation, _) =>
failAnalysis(s"Table not found: ${u.originalNameParts.quoted}")

case DescribeTable(u: UnresolvedV2Relation, _) if isView(u.originalNameParts) =>
u.failAnalysis(
s"Invalid command: '${u.originalNameParts.quoted}' is a view not a table.")

case DescribeTable(u: UnresolvedV2Relation, _) =>
failAnalysis(s"Table not found: ${u.originalNameParts.quoted}")

case u: UnresolvedV2Relation if isView(u.originalNameParts) =>
u.failAnalysis(
s"Invalid command: '${u.originalNameParts.quoted}' is a view not a table.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ case class ShowNamespaces(
*/
case class DescribeTable(table: NamedRelation, isExtended: Boolean) extends Command {

override def children: Seq[LogicalPlan] = Seq(table)
override lazy val resolved: Boolean = table.resolved

override def output: Seq[Attribute] = DescribeTableSchema.describeTableAttributes()
}
Expand Down Expand Up @@ -313,9 +313,7 @@ case class AlterTable(
table: NamedRelation,
changes: Seq[TableChange]) extends Command {

override def children: Seq[LogicalPlan] = Seq(table)

override lazy val resolved: Boolean = childrenResolved && {
override lazy val resolved: Boolean = table.resolved && {
changes.forall {
case add: AddColumn =>
add.fieldNames match {
Expand Down