-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20067] [SQL] Unify and Clean Up Desc Commands Using Catalog Interface #17394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
2ebeac8
8720919
d999147
3859097
1d72079
68bb05c
ac3f351
bef1134
29817ea
6c56041
36b501e
e116018
a6db8a3
43668be
862a4d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,15 +91,20 @@ case class CatalogTablePartition( | |
| storage: CatalogStorageFormat, | ||
| parameters: Map[String, String] = Map.empty) { | ||
|
|
||
| override def toString: String = { | ||
| private def toStringSeq: Seq[String] = { | ||
| val specString = spec.map { case (k, v) => s"$k=$v" }.mkString(", ") | ||
| val output = | ||
| Seq( | ||
| s"Partition Values: [$specString]", | ||
| s"$storage", | ||
| s"Partition Parameters:{${parameters.map(p => p._1 + "=" + p._2).mkString(", ")}}") | ||
| Seq( | ||
| s"Partition Values: [$specString]", | ||
| s"$storage", | ||
| s"Partition Parameters:{${parameters.map(p => p._1 + "=" + p._2).mkString(", ")}}") | ||
| } | ||
|
|
||
| override def toString: String = { | ||
| toStringSeq.filter(_.nonEmpty).mkString("CatalogPartition(\n\t", "\n\t", ")") | ||
| } | ||
|
|
||
| output.filter(_.nonEmpty).mkString("CatalogPartition(\n\t", "\n\t", ")") | ||
| def simpleString: String = { | ||
| toStringSeq.filter(_.nonEmpty).mkString("", "\n", "") | ||
| } | ||
|
|
||
| /** Return the partition location, assuming it is specified. */ | ||
|
|
@@ -261,7 +266,7 @@ case class CatalogTable( | |
| locationUri, inputFormat, outputFormat, serde, compressed, properties)) | ||
| } | ||
|
|
||
| override def toString: String = { | ||
| private def toStringSeq: Seq[String] = { | ||
| val tableProperties = properties.map(p => p._1 + "=" + p._2).mkString("[", ", ", "]") | ||
| val partitionColumns = partitionColumnNames.map(quoteIdentifier).mkString("[", ", ", "]") | ||
| val bucketStrings = bucketSpec match { | ||
|
|
@@ -273,28 +278,32 @@ case class CatalogTable( | |
| if (bucketColumnNames.nonEmpty) s"Bucket Columns: $bucketColumnsString" else "", | ||
| if (sortColumnNames.nonEmpty) s"Sort Columns: $sortColumnsString" else "" | ||
| ) | ||
|
|
||
| case _ => Nil | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should de-duplicate the codes. |
||
|
|
||
| val output = | ||
| Seq(s"Table: ${identifier.quotedString}", | ||
| if (owner.nonEmpty) s"Owner: $owner" else "", | ||
| s"Created: ${new Date(createTime).toString}", | ||
| s"Last Access: ${new Date(lastAccessTime).toString}", | ||
| s"Type: ${tableType.name}", | ||
| if (schema.nonEmpty) s"Schema: ${schema.mkString("[", ", ", "]")}" else "", | ||
| if (provider.isDefined) s"Provider: ${provider.get}" else "", | ||
| if (partitionColumnNames.nonEmpty) s"Partition Columns: $partitionColumns" else "" | ||
| ) ++ bucketStrings ++ Seq( | ||
| viewText.map("View: " + _).getOrElse(""), | ||
| comment.map("Comment: " + _).getOrElse(""), | ||
| if (properties.nonEmpty) s"Properties: $tableProperties" else "", | ||
| if (stats.isDefined) s"Statistics: ${stats.get.simpleString}" else "", | ||
| s"$storage", | ||
| if (tracksPartitionsInCatalog) "Partition Provider: Catalog" else "") | ||
|
|
||
| output.filter(_.nonEmpty).mkString("CatalogTable(\n\t", "\n\t", ")") | ||
| Seq(s"Table: ${identifier.quotedString}", | ||
| if (owner.nonEmpty) s"Owner: $owner" else "", | ||
| s"Created: ${new Date(createTime).toString}", | ||
| s"Last Access: ${new Date(lastAccessTime).toString}", | ||
| s"Type: ${tableType.name}", | ||
| if (provider.isDefined) s"Provider: ${provider.get}" else "", | ||
| if (partitionColumnNames.nonEmpty) s"Partition Columns: $partitionColumns" else "" | ||
| ) ++ bucketStrings ++ Seq( | ||
| viewText.map("View: " + _).getOrElse(""), | ||
| comment.map("Comment: " + _).getOrElse(""), | ||
| if (properties.nonEmpty) s"Properties: $tableProperties" else "", | ||
| if (stats.isDefined) s"Statistics: ${stats.get.simpleString}" else "", | ||
| s"$storage", | ||
| if (tracksPartitionsInCatalog) "Partition Provider: Catalog" else "", | ||
| if (schema.nonEmpty) s"Schema: ${schema.treeString}" else "") | ||
| } | ||
|
|
||
| override def toString: String = { | ||
| toStringSeq.filter(_.nonEmpty).mkString("CatalogTable(\n", "\n", ")") | ||
| } | ||
|
|
||
| def simpleString: String = { | ||
| toStringSeq.filter(_.nonEmpty).mkString("", "\n", "") | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,13 +23,13 @@ DESCRIBE t | |
| -- !query 2 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 2 output | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| a string | ||
| b int | ||
| c string | ||
| c string | ||
| d string | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| c string | ||
| d string | ||
|
|
||
|
|
||
|
|
@@ -38,13 +38,13 @@ DESC t | |
| -- !query 3 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 3 output | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| a string | ||
| b int | ||
| c string | ||
| c string | ||
| d string | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| c string | ||
| d string | ||
|
|
||
|
|
||
|
|
@@ -53,13 +53,13 @@ DESC TABLE t | |
| -- !query 4 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 4 output | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| a string | ||
| b int | ||
| c string | ||
| c string | ||
| d string | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| c string | ||
| d string | ||
|
|
||
|
|
||
|
|
@@ -68,67 +68,74 @@ DESC FORMATTED t | |
| -- !query 5 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 5 output | ||
| # Detailed Table Information | ||
| a string | ||
| b int | ||
| c string | ||
| d string | ||
| # Partition Information | ||
| # Storage Information | ||
| # col_name data_type comment | ||
| Comment: table_comment | ||
| Compressed: No | ||
| Created: | ||
| c string | ||
| d string | ||
|
|
||
| # Detailed Table Information | ||
| Database: default | ||
| Owner: | ||
| Created: | ||
| Last Access: | ||
| Location: sql/core/spark-warehouse/t | ||
| Owner: | ||
| Partition Provider: Catalog | ||
| Storage Desc Parameters: | ||
| Table Parameters: | ||
| Table Type: MANAGED | ||
| a string | ||
| b int | ||
| c string | ||
| c string | ||
| d string | ||
| d string | ||
| Comment: table_comment | ||
| Table Parameters: | ||
|
|
||
| # Storage Information | ||
| Compressed: No | ||
| Storage Desc Parameters: | ||
| Partition Provider: Catalog | ||
|
|
||
|
|
||
| -- !query 6 | ||
| DESC EXTENDED t | ||
| -- !query 6 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 6 output | ||
| # Detailed Table Information CatalogTable( | ||
| Table: `default`.`t` | ||
| Created: | ||
| Last Access: | ||
| Type: MANAGED | ||
| Schema: [StructField(a,StringType,true), StructField(b,IntegerType,true), StructField(c,StringType,true), StructField(d,StringType,true)] | ||
| Provider: parquet | ||
| Partition Columns: [`c`, `d`] | ||
| Comment: table_comment | ||
| Storage(Location: sql/core/spark-warehouse/t) | ||
| Partition Provider: Catalog) | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| a string | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should add a header here
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| b int | ||
| c string | ||
| d string | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| c string | ||
| d string | ||
| d string | ||
|
|
||
| # Detailed Table Information | ||
| Table: `default`.`t` | ||
| Created: | ||
| Last Access: | ||
| Type: MANAGED | ||
| Provider: parquet | ||
| Partition Columns: [`c`, `d`] | ||
| Comment: table_comment | ||
| Storage(Location: sql/core/spark-warehouse/t) | ||
| Partition Provider: Catalog | ||
| Schema: root | ||
| |-- a: string (nullable = true) | ||
| |-- b: integer (nullable = true) | ||
| |-- c: string (nullable = true) | ||
| |-- d: string (nullable = true) | ||
|
||
|
|
||
|
|
||
| -- !query 7 | ||
| DESC t PARTITION (c='Us', d=1) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has the same result with
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
| -- !query 7 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 7 output | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| a string | ||
| b int | ||
| c string | ||
| c string | ||
| d string | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| c string | ||
| d string | ||
|
|
||
|
|
||
|
|
@@ -137,42 +144,45 @@ DESC EXTENDED t PARTITION (c='Us', d=1) | |
| -- !query 8 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 8 output | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| Detailed Partition Information CatalogPartition( | ||
| Partition Values: [c=Us, d=1] | ||
| Storage(Location: sql/core/spark-warehouse/t/c=Us/d=1) | ||
| Partition Parameters:{}) | ||
| a string | ||
| b int | ||
| c string | ||
| d string | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| c string | ||
| d string | ||
| d string | ||
|
|
||
| Detailed Partition Information CatalogPartition( | ||
| Partition Values: [c=Us, d=1] | ||
| Storage(Location: sql/core/spark-warehouse/t/c=Us/d=1) | ||
| Partition Parameters:{}) | ||
|
|
||
|
|
||
| -- !query 9 | ||
| DESC FORMATTED t PARTITION (c='Us', d=1) | ||
| -- !query 9 schema | ||
| struct<col_name:string,data_type:string,comment:string> | ||
| -- !query 9 output | ||
| # Detailed Partition Information | ||
| # Partition Information | ||
| # Storage Information | ||
| # col_name data_type comment | ||
| Compressed: No | ||
| Database: default | ||
| Location: sql/core/spark-warehouse/t/c=Us/d=1 | ||
| Partition Parameters: | ||
| Partition Value: [Us, 1] | ||
| Storage Desc Parameters: | ||
| Table: t | ||
| a string | ||
| b int | ||
| c string | ||
| d string | ||
| # Partition Information | ||
| # col_name data_type comment | ||
| c string | ||
| d string | ||
| d string | ||
|
|
||
| # Detailed Partition Information | ||
| Partition Value: [Us, 1] | ||
| Database: default | ||
| Table: t | ||
| Location: sql/core/spark-warehouse/t/c=Us/d=1 | ||
| Partition Parameters: | ||
|
|
||
| # Storage Information | ||
| Compressed: No | ||
| Storage Desc Parameters: | ||
|
|
||
|
|
||
| -- !query 10 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when shall we call
simpleString?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show Tablecommand will call it.