Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14302#discussion_r72070878
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
    @@ -436,11 +436,13 @@ case class DescribeTableCommand(table: 
TableIdentifier, isExtended: Boolean, isF
     
       private def describePartitionInfo(table: CatalogTable, buffer: 
ArrayBuffer[Row]): Unit = {
         if (DDLUtils.isDatasourceTable(table)) {
    -      val partCols = DDLUtils.getPartitionColumnsFromTableProperties(table)
    -      if (partCols.nonEmpty) {
    +      val schema = DDLUtils.getSchemaFromTableProperties(table)
    +      val partColNames = 
DDLUtils.getPartitionColumnsFromTableProperties(table)
    +      if (partColNames.nonEmpty && schema.isDefined) {
             append(buffer, "# Partition Information", "", "")
    -        append(buffer, s"# ${output.head.name}", "", "")
    -        partCols.foreach(col => append(buffer, col, "", ""))
    +        append(buffer, s"# ${output.head.name}", output(1).name, 
output(2).name)
    +        val partCols = partColNames.map(n => schema.get.find(_.name == 
n).get)
    --- End diff --
    
    I'd rewrite the whole `if` as following:
    
    ```scala
    for (s <- schema if partColNames.nonEmpty) {
      append(buffer, "# Partition Information", "", "")
      append(buffer, s"# ${output.head.name}", output(1).name, output(2).name)
      describeSchema(StructType(partColNames.map(s(_))))
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to