mgaido91 commented on a change in pull request #23460: [SPARK-26544][SQL]
Escape string to keep alignment with hive
URL: https://github.com/apache/spark/pull/23460#discussion_r260221317
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/HiveResult.scala
##########
@@ -124,4 +124,46 @@ object HiveResult {
case (other, _ : UserDefinedType[_]) => other.toString
case (other, tpe) if primitiveTypes.contains(tpe) => other.toString
}
+
+ /** Escape a String in JSON format. */
+ private def escapeString(str: String): String = {
+ val length = str.length
+ val escape = new StringBuilder(length + 16)
+
+ str.foreach {
+ case c @ ('"' | '\\') =>
+ escape.append('\\')
+ escape.append(c);
+ case '\b' =>
+ escape.append('\\')
+ escape.append('b')
+ case '\f' =>
+ escape.append('\\')
+ escape.append('f')
+ case '\n' =>
+ escape.append('\\')
+ escape.append('n')
+ case '\r' =>
+ escape.append('\\')
+ escape.append('r')
+ case '\t' =>
+ escape.append('\\')
+ escape.append('t')
+ case c =>
+ // Control characeters! According to JSON RFC u0020
Review comment:
typo
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]