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
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.

Added test cases.

Author: Xiao Li <gatorsmile@gmail.com>

Closes #18294 from gatorsmile/tableProperties.

(cherry picked from commit df766a4)
Signed-off-by: Xiao Li <gatorsmile@gmail.com>
  • Loading branch information
gatorsmile committed Jun 14, 2017
1 parent 6265119 commit 3dda682
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 86 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 @@ -313,7 +313,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

0 comments on commit 3dda682

Please sign in to comment.