zhengruifeng commented on code in PR #57911:
URL: https://github.com/apache/spark/pull/57911#discussion_r3819577788


##########
python/pyspark/sql/conversion.py:
##########
@@ -804,13 +831,19 @@ def convert_string(value: Any) -> Any:
                     if not nullable:
                         raise PySparkValueError(f"input for {dataType} must 
not be None")
                     return None
+                elif 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
+                elif value is True:
+                    # To match the PySpark Classic which convert bool to 
string in
+                    # the JVM side (python.EvaluatePython.makeFromJava)
+                    return "true"
+                elif value is False:
+                    return "false"

Review Comment:
   ditto, numpy has `np.bool`
   
   
   ```suggestion
                   elif isinstance(value, bool):
                       return "true" if value else "false"
   ```



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

Reply via email to