xinrong-databricks commented on code in PR #36870:
URL: https://github.com/apache/spark/pull/36870#discussion_r902961587
##########
python/pyspark/sql/session.py:
##########
@@ -975,6 +976,17 @@ def createDataFrame( # type: ignore[misc]
if data.ndim not in [1, 2]:
raise ValueError("NumPy array input should be of 1 or 2
dimensions.")
column_names = ["value"] if data.ndim == 1 else ["_1", "_2"]
+ if schema is None and not self._jconf.arrowPySparkEnabled():
+ # Construct `schema` from `np.dtype` of the input NumPy array
+ # TODO: Apply the logic below when
self._jconf.arrowPySparkEnabled() is True
+ spark_type = _from_numpy_type(data.dtype)
+ if spark_type is not None:
+
Review Comment:
Good idea! Simplified.
As for `nullable`, shall we follow how we infer schema, as
[here](https://github.com/apache/spark/blob/b588d070ebc234280af730c8f9915e8859b1886e/python/pyspark/sql/types.py#L1348)?
Let me know if you have other concerns.
--
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]