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


##########
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:
   may simplify like this
   ```schema = StructType([StructField(name, spark_type, True) for name in 
column_names])```
   
   as to the `nullable=True`, should we detect where a column is `nullable`?



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