You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "itholic (via GitHub)" <gi...@apache.org> on 2023/03/12 03:01:58 UTC

[GitHub] [spark] itholic commented on a diff in pull request #40382: [SPARK-42679][CONNECT][PYTHON] createDataFrame doesn't work with non-nullable schema

itholic commented on code in PR #40382:
URL: https://github.com/apache/spark/pull/40382#discussion_r1133177990


##########
python/pyspark/sql/connect/session.py:
##########
@@ -267,6 +269,10 @@ def createDataFrame(
                 [ser._create_batch([(c, t) for (_, c), t in zip(data.items(), arrow_types)])]
             )
 
+            if isinstance(schema, StructType):
+                assert arrow_schema is not None

Review Comment:
   May dumb question, but just out of curiosity: is there any change that we get `None` for `arrow_schema`??
   
   Seems like `to_arrow_schema` function always return `pyarrow.Field` since it uses `pa.field` to create the schema? 



##########
python/pyspark/sql/connect/types.py:
##########
@@ -309,9 +309,12 @@ def to_arrow_type(dt: DataType) -> "pa.DataType":
     elif type(dt) == DayTimeIntervalType:
         arrow_type = pa.duration("us")
     elif type(dt) == ArrayType:
-        arrow_type = pa.list_(to_arrow_type(dt.elementType))
+        field = pa.field("element", to_arrow_type(dt.elementType), nullable=dt.containsNull)

Review Comment:
   Oh... so we didn't pass the nullable information to `pa._list`....
   
   Thanks for fixing this!!



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org