Skip to content

Commit

Permalink
[SPARK-21089][SQL] Fix DESC EXTENDED/FORMATTED to Show Table Properties
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

Since both table properties and storage properties share the same key values, table properties are not shown in the output of DESC EXTENDED/FORMATTED when the storage properties are not empty.

This PR is to fix the above issue by renaming them to different keys.

### How was this patch tested?
Added test cases.

Author: Xiao Li <gatorsmile@gmail.com>

Closes #18294 from gatorsmile/tableProperties.
  • Loading branch information
gatorsmile committed Jun 14, 2017
1 parent 0c88e8d commit df766a4
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 87 deletions.
Expand Up @@ -75,7 +75,7 @@ case class CatalogStorageFormat(
CatalogUtils.maskCredentials(properties) match {
case props if props.isEmpty => // No-op
case props =>
map.put("Properties", props.map(p => p._1 + "=" + p._2).mkString("[", ", ", "]"))
map.put("Storage Properties", props.map(p => p._1 + "=" + p._2).mkString("[", ", ", "]"))
}
map
}
Expand Down Expand Up @@ -316,7 +316,7 @@ case class CatalogTable(
}
}

if (properties.nonEmpty) map.put("Properties", tableProperties)
if (properties.nonEmpty) map.put("Table Properties", tableProperties)
stats.foreach(s => map.put("Statistics", s.simpleString))
map ++= storage.toLinkedHashMap
if (tracksPartitionsInCatalog) map.put("Partition Provider", "Catalog")
Expand Down
3 changes: 3 additions & 0 deletions sql/core/src/test/resources/sql-tests/inputs/describe.sql
@@ -1,4 +1,5 @@
CREATE TABLE t (a STRING, b INT, c STRING, d STRING) USING parquet
OPTIONS (a '1', b '2')
PARTITIONED BY (c, d) CLUSTERED BY (a) SORTED BY (b ASC) INTO 2 BUCKETS
COMMENT 'table_comment';

Expand All @@ -13,6 +14,8 @@ CREATE TEMPORARY VIEW temp_Data_Source_View

CREATE VIEW v AS SELECT * FROM t;

ALTER TABLE t SET TBLPROPERTIES (e = '3');

ALTER TABLE t ADD PARTITION (c='Us', d=1);

DESCRIBE t;
Expand Down
Expand Up @@ -57,7 +57,7 @@ Last Access [not included in comparison]
Type MANAGED
Provider parquet
Comment modified comment
Properties [type=parquet]
Table Properties [type=parquet]
Location [not included in comparison]sql/core/spark-warehouse/table_with_comment


Expand Down

0 comments on commit df766a4

Please sign in to comment.