cloud-fan commented on a change in pull request #31474: URL: https://github.com/apache/spark/pull/31474#discussion_r570267617
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala ########## @@ -325,11 +325,13 @@ case class AlterNamespaceSetLocation( */ case class ShowNamespaces( namespace: LogicalPlan, - pattern: Option[String]) extends Command { + pattern: Option[String], + override val output: Seq[Attribute] = ShowNamespaces.OUTPUT) extends Command { Review comment: I think it's better to put the `output` field in the constructor so that it's more stable (copying the node will not regenerate the output attributes). It also helps if we want to support self-join later. ########## File path: sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/ShowNamespacesSuite.scala ########## @@ -38,6 +38,12 @@ trait ShowNamespacesSuiteBase extends command.ShowNamespacesSuiteBase { }.getMessage assert(errMsg.contains("Namespace 'dummy' not found")) } + + test("SPARK-34359: keep the legacy output schema") { + withSQLConf(SQLConf.LEGACY_KEEP_COMMAND_OUTPUT_SCHEMA.key -> "true") { + assert(sql("SHOW NAMESPACES").schema.fieldNames.toSeq == Seq("databaseName")) Review comment: Usually, people don't rely on the output schema of commands, but some BI tools may rely on it and users are not able to update the BI tools. That's why I think it deserves a legacy config. ########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala ########## @@ -325,11 +325,13 @@ case class AlterNamespaceSetLocation( */ case class ShowNamespaces( namespace: LogicalPlan, - pattern: Option[String]) extends Command { + pattern: Option[String], + override val output: Seq[Attribute] = ShowNamespaces.OUTPUT) extends Command { Review comment: I think it's better to put the `output` field in the constructor so that it's more stable (copying the node will not regenerate the output attributes again). It also helps if we want to support self-join later. ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org