This is an automated email from the ASF dual-hosted git repository.

wenchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 850990f  [SPARK-34238][SQL] Unify output of SHOW PARTITIONS and pass 
output attributes properly
850990f is described below

commit 850990f40e5cd71e4c455320965b26df9f3be202
Author: Angerszhuuuu <[email protected]>
AuthorDate: Thu Jan 28 05:13:19 2021 +0000

    [SPARK-34238][SQL] Unify output of SHOW PARTITIONS and pass output 
attributes properly
    
    ### What changes were proposed in this pull request?
    Passing around the output attributes should have more benefits like keeping 
the expr ID unchanged to avoid bugs when we apply more operators above the 
command output dataframe.
    
    This PR keep SHOW PARTITIONS command's output attribute exprId unchanged.
    And benefit for https://issues.apache.org/jira/browse/SPARK-34238
    ### Why are the changes needed?
     Keep SHOW PARTITIONS command's output attribute exprid unchanged.
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    Added UT
    
    Closes #31341 from AngersZhuuuu/SPARK-34238.
    
    Authored-by: Angerszhuuuu <[email protected]>
    Signed-off-by: Wenchen Fan <[email protected]>
---
 .../apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala    | 3 ++-
 .../main/scala/org/apache/spark/sql/execution/command/tables.scala    | 4 +---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 
b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
index 16cd206..ae74a7a 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
@@ -414,11 +414,12 @@ class ResolveSessionCatalog(
         ident.asTableIdentifier,
         partitionSpec)
 
-    case ShowPartitions(
+    case s @ ShowPartitions(
         ResolvedV1TableOrViewIdentifier(ident),
         pattern @ (None | Some(UnresolvedPartitionSpec(_, _)))) =>
       ShowPartitionsCommand(
         ident.asTableIdentifier,
+        s.output,
         pattern.map(_.asInstanceOf[UnresolvedPartitionSpec].spec))
 
     case ShowColumns(ResolvedV1TableOrViewIdentifier(ident), ns) =>
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
index 63efbb6..cd89872 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
@@ -968,10 +968,8 @@ case class ShowColumnsCommand(
  */
 case class ShowPartitionsCommand(
     tableName: TableIdentifier,
+    override val output: Seq[Attribute],
     spec: Option[TablePartitionSpec]) extends RunnableCommand {
-  override val output: Seq[Attribute] = {
-    AttributeReference("partition", StringType, nullable = false)() :: Nil
-  }
 
   override def run(sparkSession: SparkSession): Seq[Row] = {
     val catalog = sparkSession.sessionState.catalog


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to