You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/12/08 14:54:35 UTC
[GitHub] [spark] srowen commented on a change in pull request #30647: [SPARK-33690][SQL] Escape meta-characters in showString
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org