Yicong-Huang commented on code in PR #57911:
URL: https://github.com/apache/spark/pull/57911#discussion_r3781242551
##########
python/pyspark/sql/conversion.py:
##########
@@ -804,13 +830,16 @@ def convert_string(value: Any) -> Any:
if not nullable:
raise PySparkValueError(f"input for {dataType} must
not be None")
return None
- else:
- if isinstance(value, bool):
- # To match the PySpark Classic which convert bool to
string in
- # the JVM side (python.EvaluatePython.makeFromJava)
- return str(value).lower()
- else:
- return str(value)
+ if type(value) is str:
+ # Fast path: `str(value)` returns `value` itself for a
`str`
+ # input (no copy), but still pays the constructor dispatch
per
+ # element. Returning it directly skips that and the bool
check.
+ return value
+ if isinstance(value, bool):
Review Comment:
This indeed helped a bit, changed as suggested
--
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]