zhengruifeng commented on code in PR #41931:
URL: https://github.com/apache/spark/pull/41931#discussion_r1259314468
##########
python/pyspark/pandas/sql_formatter.py:
##########
@@ -265,7 +266,14 @@ 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():
+ special_characters = ["\\", "'", '"', "\0", "\b", "\n", "\r",
"\t"]
+ escaped_val = val
+ for char in special_characters:
+ escaped_val = escaped_val.replace(char, "\\" + char)
+ return f"'{escaped_val}'"
Review Comment:
+1, `Literal.sql` seems much more complex
https://github.com/apache/spark/blob/1c057f5959c922ff59fd7648ece0dbe9a16aa286/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala#L476-L541
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]