[SPARK-34239][SQL][FOLLOW_UP] SHOW COLUMNS Keep consistence with other SHOW command

### What changes were proposed in this pull request?
Keep consistence with other `SHOW` command according to  https://github.com/apache/spark/pull/31341#issuecomment-774613080

### Why are the changes needed?
Keep consistence

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Not need

Closes #31518 from AngersZhuuuu/SPARK-34239-followup.

Authored-by: Angerszhuuuu <angers.zhu@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
This commit is contained in:
Angerszhuuuu 2021-02-08 11:39:59 +00:00 committed by Wenchen Fan
parent 2c243c93d9
commit 70a79e920a
3 changed files with 8 additions and 7 deletions

View file

@ -743,12 +743,13 @@ case class ShowCreateTable(child: LogicalPlan, asSerde: Boolean = false) extends
*/ */
case class ShowColumns( case class ShowColumns(
child: LogicalPlan, child: LogicalPlan,
namespace: Option[Seq[String]]) extends Command { namespace: Option[Seq[String]],
override val output: Seq[Attribute] = ShowColumns.OUTPUT) extends Command {
override def children: Seq[LogicalPlan] = child :: Nil override def children: Seq[LogicalPlan] = child :: Nil
}
override val output: Seq[Attribute] = { object ShowColumns {
AttributeReference("col_name", StringType, nullable = false)() :: Nil val OUTPUT: Seq[Attribute] = Seq(AttributeReference("col_name", StringType, nullable = false)())
}
} }
/** /**

View file

@ -407,7 +407,7 @@ class ResolveSessionCatalog(val catalogManager: CatalogManager)
s.output, s.output,
pattern.map(_.asInstanceOf[UnresolvedPartitionSpec].spec)) pattern.map(_.asInstanceOf[UnresolvedPartitionSpec].spec))
case s @ ShowColumns(ResolvedV1TableOrViewIdentifier(ident), ns) => case s @ ShowColumns(ResolvedV1TableOrViewIdentifier(ident), ns, output) =>
val v1TableName = ident.asTableIdentifier val v1TableName = ident.asTableIdentifier
val resolver = conf.resolver val resolver = conf.resolver
val db = ns match { val db = ns match {
@ -415,7 +415,7 @@ class ResolveSessionCatalog(val catalogManager: CatalogManager)
throw QueryCompilationErrors.showColumnsWithConflictDatabasesError(db, v1TableName) throw QueryCompilationErrors.showColumnsWithConflictDatabasesError(db, v1TableName)
case _ => ns.map(_.head) case _ => ns.map(_.head)
} }
ShowColumnsCommand(db, v1TableName, s.output) ShowColumnsCommand(db, v1TableName, output)
case AlterTableRecoverPartitions(ResolvedV1TableIdentifier(ident)) => case AlterTableRecoverPartitions(ResolvedV1TableIdentifier(ident)) =>
AlterTableRecoverPartitionsCommand( AlterTableRecoverPartitionsCommand(

View file

@ -400,7 +400,7 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat
case TruncateTable(_: ResolvedTable, _) => case TruncateTable(_: ResolvedTable, _) =>
throw new AnalysisException("TRUNCATE TABLE is not supported for v2 tables.") throw new AnalysisException("TRUNCATE TABLE is not supported for v2 tables.")
case ShowColumns(_: ResolvedTable, _) => case ShowColumns(_: ResolvedTable, _, _) =>
throw new AnalysisException("SHOW COLUMNS is not supported for v2 tables.") throw new AnalysisException("SHOW COLUMNS is not supported for v2 tables.")
case r @ ShowPartitions( case r @ ShowPartitions(