maropu commented on a change in pull request #31144:
URL: https://github.com/apache/spark/pull/31144#discussion_r556165408



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
##########
@@ -310,7 +310,14 @@ class Dataset[T] private[sql](
           case binary: Array[Byte] => 
binary.map("%02X".format(_)).mkString("[", " ", "]")
           case _ =>
             // Escapes meta-characters not to break the `showString` format
-            cell.toString.replaceAll("\n", "\\\\n").replaceAll("\t", "\\\\t")
+            cell.toString
+              .replaceAll("\n", "\\\\n")
+              .replaceAll("\r", "\\\\r")
+              .replaceAll("\t", "\\\\t")
+              .replaceAll("\f", "\\\\f")
+              .replaceAll("\b", "\\\\b")
+              .replaceAll("\u000B", "\\\\v")
+              .replaceAll("\u0007", "\\\\a")

Review comment:
       It seems `fieldNames` (L306) has the same issue, so could you fix it in 
this PR, too?
   ```
   scala> spark.range(1).selectExpr("'aaa\nbbb'").show()
   +--------+                                                                   
   
   | aaa
   bbb|
   +--------+
   |aaa\nbbb|
   +--------+
   ```




----------------------------------------------------------------
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