srowen commented on a change in pull request #30647:
URL: https://github.com/apache/spark/pull/30647#discussion_r538461120



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
##########
@@ -304,10 +304,13 @@ class Dataset[T] private[sql](
     // For cells that are beyond `truncate` characters, replace it with the
     // first `truncate-3` and "..."
     schema.fieldNames.toSeq +: data.map { row =>
-      row.toSeq.map { cell =>
+      row.toSeq.zip(newDf.schema).map { case (cell, f) =>
         val str = cell match {
           case null => "null"
           case binary: Array[Byte] => 
binary.map("%02X".format(_)).mkString("[", " ", "]")
+          case _ if f.dataType == StringType =>
+            // Escapes meta-characters not to break the `showString` format
+            cell.toString.replaceAll("\n", "\\\\n").replaceAll("\t", "\\\\t")

Review comment:
       Just for my curiosity, why is `\\\\t` necessary? the extra escaping? 
this seems to replace with the string `\\t` rather than `\t`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to