Skip to content

Commit

Permalink
[SPARK-34238][SQL] Unify output of SHOW PARTITIONS and pass output at…
Browse files Browse the repository at this point in the history
…tributes 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 apache#31341 from AngersZhuuuu/SPARK-34238.

Authored-by: Angerszhuuuu <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
  • Loading branch information
AngersZhuuuu authored and cloud-fan committed Jan 28, 2021
1 parent 01d11da commit 850990f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 850990f

Please sign in to comment.