From 0afc9f704100b7dda94de7eb50569248a9444b55 Mon Sep 17 00:00:00 2001 From: Zhenhua Wang Date: Wed, 13 Sep 2017 09:25:52 +0800 Subject: [PATCH 1/3] improve comments --- .../org/apache/spark/sql/execution/command/tables.scala | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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 da0c815581d53..8d95ca6921cf8 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 @@ -632,8 +632,7 @@ case class DescribeTableCommand( } /** - * A command to list the info for a column, including name, data type, column stats and comment. - * This function creates a [[DescribeColumnCommand]] logical plan. + * A command to list the info for a column, including name, data type, comment and column stats. * * The syntax of using this command in SQL is: * {{{ @@ -809,8 +808,7 @@ case class ShowTablePropertiesCommand(table: TableIdentifier, propertyKey: Optio } /** - * A command to list the column names for a table. This function creates a - * [[ShowColumnsCommand]] logical plan. + * A command to list the column names for a table. * * The syntax of using this command in SQL is: * {{{ @@ -849,8 +847,6 @@ case class ShowColumnsCommand( * 1. If the command is called for a non partitioned table. * 2. If the partition spec refers to the columns that are not defined as partitioning columns. * - * This function creates a [[ShowPartitionsCommand]] logical plan - * * The syntax of using this command in SQL is: * {{{ * SHOW PARTITIONS [db_name.]table_name [PARTITION(partition_spec)] From d922c85fe6e462df122450ed015c0a7e722d2e2c Mon Sep 17 00:00:00 2001 From: Zhenhua Wang Date: Thu, 14 Sep 2017 09:34:05 +0800 Subject: [PATCH 2/3] drop tables --- .../inputs/describe-table-column.sql | 14 +++- .../results/describe-table-column.sql.out | 78 ++++++++++++------- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/describe-table-column.sql b/sql/core/src/test/resources/sql-tests/inputs/describe-table-column.sql index 24870def0316e..db4709505ef5b 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/describe-table-column.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/describe-table-column.sql @@ -13,6 +13,8 @@ DESC FORMATTED desc_col_temp_table desc_col_temp_table.key; -- Describe a non-existent column DESC desc_col_temp_table key1; +DROP VIEW desc_col_temp_table; + -- Test persistent table CREATE TABLE desc_col_table (key int COMMENT 'column_comment') USING PARQUET; @@ -24,12 +26,16 @@ DESC EXTENDED desc_col_table key; DESC FORMATTED desc_col_table key; +DROP TABLE desc_col_table; + -- Test complex columns -CREATE TABLE desc_col_complex_table (`a.b` int, col struct) USING PARQUET; +CREATE TABLE desc_complex_col_table (`a.b` int, col struct) USING PARQUET; -DESC FORMATTED desc_col_complex_table `a.b`; +DESC FORMATTED desc_complex_col_table `a.b`; -DESC FORMATTED desc_col_complex_table col; +DESC FORMATTED desc_complex_col_table col; -- Describe a nested column -DESC FORMATTED desc_col_complex_table col.x; +DESC FORMATTED desc_complex_col_table col.x; + +DROP TABLE desc_complex_col_table; diff --git a/sql/core/src/test/resources/sql-tests/results/describe-table-column.sql.out b/sql/core/src/test/resources/sql-tests/results/describe-table-column.sql.out index a51eef7c7e1f6..23e35e68d0eec 100644 --- a/sql/core/src/test/resources/sql-tests/results/describe-table-column.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/describe-table-column.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 15 +-- Number of queries: 18 -- !query 0 @@ -78,7 +78,7 @@ Column key1 does not exist; -- !query 6 -CREATE TABLE desc_col_table (key int COMMENT 'column_comment') USING PARQUET +DROP VIEW desc_col_temp_table -- !query 6 schema struct<> -- !query 6 output @@ -86,7 +86,7 @@ struct<> -- !query 7 -ANALYZE TABLE desc_col_table COMPUTE STATISTICS FOR COLUMNS key +CREATE TABLE desc_col_table (key int COMMENT 'column_comment') USING PARQUET -- !query 7 schema struct<> -- !query 7 output @@ -94,20 +94,28 @@ struct<> -- !query 8 -DESC desc_col_table key +ANALYZE TABLE desc_col_table COMPUTE STATISTICS FOR COLUMNS key -- !query 8 schema -struct +struct<> -- !query 8 output + + + +-- !query 9 +DESC desc_col_table key +-- !query 9 schema +struct +-- !query 9 output col_name key data_type int comment column_comment --- !query 9 +-- !query 10 DESC EXTENDED desc_col_table key --- !query 9 schema +-- !query 10 schema struct --- !query 9 output +-- !query 10 output col_name key data_type int comment column_comment @@ -119,11 +127,11 @@ avg_col_len 4 max_col_len 4 --- !query 10 +-- !query 11 DESC FORMATTED desc_col_table key --- !query 10 schema +-- !query 11 schema struct --- !query 10 output +-- !query 11 output col_name key data_type int comment column_comment @@ -135,19 +143,27 @@ avg_col_len 4 max_col_len 4 --- !query 11 -CREATE TABLE desc_col_complex_table (`a.b` int, col struct) USING PARQUET --- !query 11 schema +-- !query 12 +DROP TABLE desc_col_table +-- !query 12 schema struct<> --- !query 11 output +-- !query 12 output --- !query 12 -DESC FORMATTED desc_col_complex_table `a.b` --- !query 12 schema +-- !query 13 +CREATE TABLE desc_complex_col_table (`a.b` int, col struct) USING PARQUET +-- !query 13 schema +struct<> +-- !query 13 output + + + +-- !query 14 +DESC FORMATTED desc_complex_col_table `a.b` +-- !query 14 schema struct --- !query 12 output +-- !query 14 output col_name a.b data_type int comment NULL @@ -159,11 +175,11 @@ avg_col_len NULL max_col_len NULL --- !query 13 -DESC FORMATTED desc_col_complex_table col --- !query 13 schema +-- !query 15 +DESC FORMATTED desc_complex_col_table col +-- !query 15 schema struct --- !query 13 output +-- !query 15 output col_name col data_type struct comment NULL @@ -175,10 +191,18 @@ avg_col_len NULL max_col_len NULL --- !query 14 -DESC FORMATTED desc_col_complex_table col.x --- !query 14 schema +-- !query 16 +DESC FORMATTED desc_complex_col_table col.x +-- !query 16 schema struct<> --- !query 14 output +-- !query 16 output org.apache.spark.sql.AnalysisException DESC TABLE COLUMN command does not support nested data types: col.x; + + +-- !query 17 +DROP TABLE desc_complex_col_table +-- !query 17 schema +struct<> +-- !query 17 output + From a995edc26d9e4d6803973095b3092a5ca50639d6 Mon Sep 17 00:00:00 2001 From: Zhenhua Wang Date: Thu, 14 Sep 2017 15:57:08 +0800 Subject: [PATCH 3/3] fix comments --- .../inputs/describe-table-column.sql | 20 ++--- .../results/describe-table-column.sql.out | 88 +++++++++---------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/inputs/describe-table-column.sql b/sql/core/src/test/resources/sql-tests/inputs/describe-table-column.sql index db4709505ef5b..a6ddcd999bf9b 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/describe-table-column.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/describe-table-column.sql @@ -1,19 +1,17 @@ -- Test temp table -CREATE TEMPORARY VIEW desc_col_temp_table (key int COMMENT 'column_comment') USING PARQUET; +CREATE TEMPORARY VIEW desc_col_temp_view (key int COMMENT 'column_comment') USING PARQUET; -DESC desc_col_temp_table key; +DESC desc_col_temp_view key; -DESC EXTENDED desc_col_temp_table key; +DESC EXTENDED desc_col_temp_view key; -DESC FORMATTED desc_col_temp_table key; +DESC FORMATTED desc_col_temp_view key; -- Describe a column with qualified name -DESC FORMATTED desc_col_temp_table desc_col_temp_table.key; +DESC FORMATTED desc_col_temp_view desc_col_temp_view.key; -- Describe a non-existent column -DESC desc_col_temp_table key1; - -DROP VIEW desc_col_temp_table; +DESC desc_col_temp_view key1; -- Test persistent table CREATE TABLE desc_col_table (key int COMMENT 'column_comment') USING PARQUET; @@ -26,8 +24,6 @@ DESC EXTENDED desc_col_table key; DESC FORMATTED desc_col_table key; -DROP TABLE desc_col_table; - -- Test complex columns CREATE TABLE desc_complex_col_table (`a.b` int, col struct) USING PARQUET; @@ -38,4 +34,8 @@ DESC FORMATTED desc_complex_col_table col; -- Describe a nested column DESC FORMATTED desc_complex_col_table col.x; +DROP VIEW desc_col_temp_view; + +DROP TABLE desc_col_table; + DROP TABLE desc_complex_col_table; diff --git a/sql/core/src/test/resources/sql-tests/results/describe-table-column.sql.out b/sql/core/src/test/resources/sql-tests/results/describe-table-column.sql.out index 23e35e68d0eec..30d0a2dc5a3f7 100644 --- a/sql/core/src/test/resources/sql-tests/results/describe-table-column.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/describe-table-column.sql.out @@ -3,7 +3,7 @@ -- !query 0 -CREATE TEMPORARY VIEW desc_col_temp_table (key int COMMENT 'column_comment') USING PARQUET +CREATE TEMPORARY VIEW desc_col_temp_view (key int COMMENT 'column_comment') USING PARQUET -- !query 0 schema struct<> -- !query 0 output @@ -11,7 +11,7 @@ struct<> -- !query 1 -DESC desc_col_temp_table key +DESC desc_col_temp_view key -- !query 1 schema struct -- !query 1 output @@ -21,7 +21,7 @@ comment column_comment -- !query 2 -DESC EXTENDED desc_col_temp_table key +DESC EXTENDED desc_col_temp_view key -- !query 2 schema struct -- !query 2 output @@ -37,7 +37,7 @@ max_col_len NULL -- !query 3 -DESC FORMATTED desc_col_temp_table key +DESC FORMATTED desc_col_temp_view key -- !query 3 schema struct -- !query 3 output @@ -53,7 +53,7 @@ max_col_len NULL -- !query 4 -DESC FORMATTED desc_col_temp_table desc_col_temp_table.key +DESC FORMATTED desc_col_temp_view desc_col_temp_view.key -- !query 4 schema struct -- !query 4 output @@ -69,7 +69,7 @@ max_col_len NULL -- !query 5 -DESC desc_col_temp_table key1 +DESC desc_col_temp_view key1 -- !query 5 schema struct<> -- !query 5 output @@ -78,7 +78,7 @@ Column key1 does not exist; -- !query 6 -DROP VIEW desc_col_temp_table +CREATE TABLE desc_col_table (key int COMMENT 'column_comment') USING PARQUET -- !query 6 schema struct<> -- !query 6 output @@ -86,7 +86,7 @@ struct<> -- !query 7 -CREATE TABLE desc_col_table (key int COMMENT 'column_comment') USING PARQUET +ANALYZE TABLE desc_col_table COMPUTE STATISTICS FOR COLUMNS key -- !query 7 schema struct<> -- !query 7 output @@ -94,28 +94,20 @@ struct<> -- !query 8 -ANALYZE TABLE desc_col_table COMPUTE STATISTICS FOR COLUMNS key --- !query 8 schema -struct<> --- !query 8 output - - - --- !query 9 DESC desc_col_table key --- !query 9 schema +-- !query 8 schema struct --- !query 9 output +-- !query 8 output col_name key data_type int comment column_comment --- !query 10 +-- !query 9 DESC EXTENDED desc_col_table key --- !query 10 schema +-- !query 9 schema struct --- !query 10 output +-- !query 9 output col_name key data_type int comment column_comment @@ -127,11 +119,11 @@ avg_col_len 4 max_col_len 4 --- !query 11 +-- !query 10 DESC FORMATTED desc_col_table key --- !query 11 schema +-- !query 10 schema struct --- !query 11 output +-- !query 10 output col_name key data_type int comment column_comment @@ -143,27 +135,19 @@ avg_col_len 4 max_col_len 4 --- !query 12 -DROP TABLE desc_col_table --- !query 12 schema -struct<> --- !query 12 output - - - --- !query 13 +-- !query 11 CREATE TABLE desc_complex_col_table (`a.b` int, col struct) USING PARQUET --- !query 13 schema +-- !query 11 schema struct<> --- !query 13 output +-- !query 11 output --- !query 14 +-- !query 12 DESC FORMATTED desc_complex_col_table `a.b` --- !query 14 schema +-- !query 12 schema struct --- !query 14 output +-- !query 12 output col_name a.b data_type int comment NULL @@ -175,11 +159,11 @@ avg_col_len NULL max_col_len NULL --- !query 15 +-- !query 13 DESC FORMATTED desc_complex_col_table col --- !query 15 schema +-- !query 13 schema struct --- !query 15 output +-- !query 13 output col_name col data_type struct comment NULL @@ -191,15 +175,31 @@ avg_col_len NULL max_col_len NULL --- !query 16 +-- !query 14 DESC FORMATTED desc_complex_col_table col.x --- !query 16 schema +-- !query 14 schema struct<> --- !query 16 output +-- !query 14 output org.apache.spark.sql.AnalysisException DESC TABLE COLUMN command does not support nested data types: col.x; +-- !query 15 +DROP VIEW desc_col_temp_view +-- !query 15 schema +struct<> +-- !query 15 output + + + +-- !query 16 +DROP TABLE desc_col_table +-- !query 16 schema +struct<> +-- !query 16 output + + + -- !query 17 DROP TABLE desc_complex_col_table -- !query 17 schema