itholic commented on code in PR #41931:
URL: https://github.com/apache/spark/pull/41931#discussion_r1260402845


##########
python/pyspark/pandas/sql_formatter.py:
##########
@@ -265,7 +266,13 @@ def _convert_value(self, val: Any, name: str) -> 
Optional[str]:
             val._to_spark().createOrReplaceTempView(df_name)
             return df_name
         elif isinstance(val, str):
-            return lit(val)._jc.expr().sql()  # for escaped characters.
+            if is_remote():
+                # This is matched to behavior from JVM implementation.
+                # See `sql` definition from 
`sql/catalyst/src/main/scala/org/apache/spark/
+                # sql/catalyst/expressions/literals.scala`
+                return "'" + val.replace("\\", "\\\\").replace("'", "\\'") + 
"'"
+            else:
+                return lit(val)._jc.expr().sql()  # for escaped characters.

Review Comment:
   Sounds good



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

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to