wangyum commented on a change in pull request #32563:
URL: https://github.com/apache/spark/pull/32563#discussion_r634924338
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala
##########
@@ -580,41 +587,52 @@ case class RenameTable(
*/
case class ShowTables(
namespace: LogicalPlan,
- pattern: Option[String],
- override val output: Seq[Attribute] = ShowTables.getOutputAttrs) extends
UnaryCommand {
+ pattern: Option[String]) extends UnaryCommand {
+ override val output: Seq[Attribute] = {
+ val tableName = AttributeReference("tableName", StringType, nullable =
false)()
+ val isTemporary = AttributeReference("isTemporary", BooleanType, nullable
= false)()
+ if (conf.getConf(SQLConf.LEGACY_KEEP_COMMAND_OUTPUT_SCHEMA)) {
+ Seq(AttributeReference("database", StringType, nullable = false)(),
tableName, isTemporary)
+ } else {
+ Seq(AttributeReference("namespace", StringType, nullable = false)(),
tableName, isTemporary)
+ }
+ }
+
override def child: LogicalPlan = namespace
override protected def withNewChildInternal(newChild: LogicalPlan):
ShowTables =
copy(namespace = newChild)
}
-object ShowTables {
- def getOutputAttrs: Seq[Attribute] = Seq(
- AttributeReference("namespace", StringType, nullable = false)(),
- AttributeReference("tableName", StringType, nullable = false)(),
- AttributeReference("isTemporary", BooleanType, nullable = false)())
-}
-
/**
* The logical plan of the SHOW TABLE EXTENDED command.
*/
case class ShowTableExtended(
namespace: LogicalPlan,
pattern: String,
- partitionSpec: Option[PartitionSpec],
- override val output: Seq[Attribute] = ShowTableExtended.getOutputAttrs)
extends UnaryCommand {
+ partitionSpec: Option[PartitionSpec]) extends UnaryCommand {
+ override val output: Seq[Attribute] = {
+ val tableName = AttributeReference("tableName", StringType, nullable =
false)()
+ val isTemporary = AttributeReference("isTemporary", BooleanType, nullable
= false)()
+ if (conf.getConf(SQLConf.LEGACY_KEEP_COMMAND_OUTPUT_SCHEMA)) {
+ Seq(
+ AttributeReference("database", StringType, nullable = false)(),
+ tableName,
+ isTemporary,
+ AttributeReference("information", StringType, nullable = false)())
+ } else {
+ Seq(
+ AttributeReference("namespace", StringType, nullable = false)(),
+ tableName,
+ isTemporary,
+ AttributeReference("information", MapType(StringType, StringType),
nullable = false)())
+ }
Review comment:
Move the `spark.sql.legacy.keepCommandOutputSchema` logic from
`ResolveSessionCatalog` to `v2Commands`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]