zhengruifeng commented on code in PR #57911:
URL: https://github.com/apache/spark/pull/57911#discussion_r3819566066
##########
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:
Review Comment:
users can returns any type in vanilla udf, I encountered numpy/pandas
variants of python primitives in some customer reports. e.g. `np.str_`
```
In [17]: s = np.str_("123")
In [18]: isinstance(s, str)
Out[18]: True
In [19]: type(s) is str
Out[19]: False
```
i think using `isinstance` is more safer in such cases.
--
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]