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

    https://github.com/apache/spark/pull/21370#discussion_r190154231
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
    @@ -358,6 +357,43 @@ class Dataset[T] private[sql](
         sb.toString()
       }
     
    +  /**
    +   * Transform current row string and append to builder
    +   *
    +   * @param row       Current row of string
    +   * @param truncate  If set to more than 0, truncates strings to 
`truncate` characters and
    +   *                    all cells will be aligned right.
    +   * @param colWidths The width of each column
    +   * @param html      If set to true, return output as html table.
    +   * @param head      Set to true while current row is table head.
    +   * @param sb        StringBuilder for current row.
    +   */
    +  private[sql] def appendRowString(
    +      row: Seq[String],
    +      truncate: Int,
    +      colWidths: Array[Int],
    +      html: Boolean,
    +      head: Boolean,
    +      sb: StringBuilder): Unit = {
    +    val data = row.zipWithIndex.map { case (cell, i) =>
    +      if (truncate > 0) {
    +        StringUtils.leftPad(cell, colWidths(i))
    +      } else {
    +        StringUtils.rightPad(cell, colWidths(i))
    +      }
    +    }
    +    (html, head) match {
    +      case (true, true) =>
    +        data.map(StringEscapeUtils.escapeHtml).addString(
    +          sb, "<tr><th>", "</th><th>", "</th></tr>")
    --- End diff --
    
    Thanks, done. feb5f4a.


---

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

Reply via email to