[ 
https://issues.apache.org/jira/browse/SPARK-39337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

angerszhu updated SPARK-39337:
------------------------------
    Description: 
Repeated code, refactor the code.


{code:java}

  private def addTableDetails(rows: ArrayBuffer[InternalRow]): Unit = {
    rows += emptyRow()
    rows += toCatalystRow("# Detailed Table Information", "", "")
    rows += toCatalystRow("Name", table.name(), "")

    CatalogV2Util.TABLE_RESERVED_PROPERTIES.foreach(propKey => {
      if (table.properties.containsKey(propKey)) {
        rows += toCatalystRow(propKey.capitalize, 
table.properties.get(propKey), "")
      }
    })
    val properties =
      table.properties.asScala.toList
        .filter(kv => !CatalogV2Util.TABLE_RESERVED_PROPERTIES.contains(kv._1))
        .sortBy(_._1).map {
        case (key, value) => key + "=" + value
      }.mkString("[", ",", "]")
    rows += toCatalystRow("Table Properties", properties, "")
  }
{code}


  was:Repeated code, refactor the code.


> Refactor DescribeTableExec
> --------------------------
>
>                 Key: SPARK-39337
>                 URL: https://issues.apache.org/jira/browse/SPARK-39337
>             Project: Spark
>          Issue Type: Task
>          Components: SQL
>    Affects Versions: 3.3.0
>            Reporter: angerszhu
>            Priority: Major
>
> Repeated code, refactor the code.
> {code:java}
>   private def addTableDetails(rows: ArrayBuffer[InternalRow]): Unit = {
>     rows += emptyRow()
>     rows += toCatalystRow("# Detailed Table Information", "", "")
>     rows += toCatalystRow("Name", table.name(), "")
>     CatalogV2Util.TABLE_RESERVED_PROPERTIES.foreach(propKey => {
>       if (table.properties.containsKey(propKey)) {
>         rows += toCatalystRow(propKey.capitalize, 
> table.properties.get(propKey), "")
>       }
>     })
>     val properties =
>       table.properties.asScala.toList
>         .filter(kv => 
> !CatalogV2Util.TABLE_RESERVED_PROPERTIES.contains(kv._1))
>         .sortBy(_._1).map {
>         case (key, value) => key + "=" + value
>       }.mkString("[", ",", "]")
>     rows += toCatalystRow("Table Properties", properties, "")
>   }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

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

Reply via email to