zhengruifeng commented on code in PR #57911:
URL: https://github.com/apache/spark/pull/57911#discussion_r3819039975
##########
python/pyspark/sql/conversion.py:
##########
@@ -685,6 +685,27 @@ def convert_array(value: Any) -> Any:
assert isinstance(value, (list, array.array))
return list(value)
+ elif isinstance(dataType.elementType, (StringType, BinaryType)):
+ # Inline the scalar identity fast path so elements that are
+ # already the target Python type skip the per-element converter
+ # call entirely: `convert_string`/`convert_binary` return such
+ # elements unchanged. `str` and immutable `bytes` are the two
+ # element types whose converter is a no-op on a matching value.
+ # Any other element -- including `None` (whose nullability is
+ # enforced by `element_conv`) and values that need coercion
(e.g.
+ # a bool to string) -- falls back to `element_conv`, reused
+ # unchanged.
+ fast_type = str if isinstance(dataType.elementType,
StringType) else bytes
Review Comment:
i guess the fast path should check 'dataType.containsNull'?
--
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]