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

    https://github.com/apache/spark/pull/21370#discussion_r189570479
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
    @@ -292,31 +297,25 @@ class Dataset[T] private[sql](
           }
     
           // Create SeparateLine
    -      val sep: String = colWidths.map("-" * _).addString(sb, "+", "+", 
"+\n").toString()
    +      val sep: String = if (html) {
    +        // Initial append table label
    +        sb.append("<table border='1'>\n")
    +        "\n"
    +      } else {
    +        colWidths.map("-" * _).addString(sb, "+", "+", "+\n").toString()
    +      }
     
           // column names
    -      rows.head.zipWithIndex.map { case (cell, i) =>
    -        if (truncate > 0) {
    -          StringUtils.leftPad(cell, colWidths(i))
    -        } else {
    -          StringUtils.rightPad(cell, colWidths(i))
    -        }
    -      }.addString(sb, "|", "|", "|\n")
    -
    +      appendRowString(rows.head, truncate, colWidths, html, true, sb)
           sb.append(sep)
     
           // data
    -      rows.tail.foreach {
    -        _.zipWithIndex.map { case (cell, i) =>
    -          if (truncate > 0) {
    -            StringUtils.leftPad(cell.toString, colWidths(i))
    -          } else {
    -            StringUtils.rightPad(cell.toString, colWidths(i))
    -          }
    -        }.addString(sb, "|", "|", "|\n")
    +      rows.tail.foreach { row =>
    +        appendRowString(row.map(_.toString), truncate, colWidths, html, 
false, sb)
    --- End diff --
    
    I think we need this toString, because the appendRowString method including 
both column names and data in original logic, which call `toString` in data 
part.


---

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

Reply via email to