Skip to content
Snippets Groups Projects
Commit 56183b84 authored by Dongjoon Hyun's avatar Dongjoon Hyun Committed by Herman van Hovell
Browse files

[SPARK-16543][SQL] Rename the columns of `SHOW PARTITION/COLUMNS` commands

## What changes were proposed in this pull request?

This PR changes the name of columns returned by `SHOW PARTITION` and `SHOW COLUMNS` commands. Currently, both commands uses `result` as a column name.

**Comparison: Column Name**

Command|Spark(Before)|Spark(After)|Hive
----------|--------------|------------|-----
SHOW PARTITIONS|result|partition|partition
SHOW COLUMNS|result|col_name|field

Note that Spark/Hive uses `col_name` in `DESC TABLES`. So, this PR chooses `col_name` for consistency among Spark commands.

**Before**
```scala
scala> sql("show partitions p").show()
+------+
|result|
+------+
|   b=2|
+------+

scala> sql("show columns in p").show()
+------+
|result|
+------+
|     a|
|     b|
+------+
```

**After**
```scala
scala> sql("show partitions p").show
+---------+
|partition|
+---------+
|      b=2|
+---------+

scala> sql("show columns in p").show
+--------+
|col_name|
+--------+
|       a|
|       b|
+--------+
```

## How was this patch tested?

Manual.

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes #14199 from dongjoon-hyun/SPARK-16543.
parent 1b5c9e52
No related branches found
No related tags found
No related merge requests found
......@@ -622,9 +622,8 @@ case class ShowTablePropertiesCommand(table: TableIdentifier, propertyKey: Optio
* }}}
*/
case class ShowColumnsCommand(table: TableIdentifier) extends RunnableCommand {
// The result of SHOW COLUMNS has one column called 'result'
override val output: Seq[Attribute] = {
AttributeReference("result", StringType, nullable = false)() :: Nil
AttributeReference("col_name", StringType, nullable = false)() :: Nil
}
override def run(sparkSession: SparkSession): Seq[Row] = {
......@@ -652,9 +651,8 @@ case class ShowColumnsCommand(table: TableIdentifier) extends RunnableCommand {
case class ShowPartitionsCommand(
table: TableIdentifier,
spec: Option[TablePartitionSpec]) extends RunnableCommand {
// The result of SHOW PARTITIONS has one column called 'result'
override val output: Seq[Attribute] = {
AttributeReference("result", StringType, nullable = false)() :: Nil
AttributeReference("partition", StringType, nullable = false)() :: Nil
}
private def getPartName(spec: TablePartitionSpec, partColNames: Seq[String]): String = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment