harshmotw-db commented on code in PR #48770:
URL: https://github.com/apache/spark/pull/48770#discussion_r1831611328


##########
python/pyspark/sql/pandas/types.py:
##########
@@ -221,6 +221,15 @@ def to_arrow_schema(
     return pa.schema(fields)
 
 
+def is_variant(at: "pa.DataType") -> bool:
+    """Check if a PyArrow struct data type represents a variant"""
+    import pyarrow.types as types
+    assert types.is_struct(at)

Review Comment:
   This function is intended to be called with `at.is_struct` so I want to 
prevent developers from using this function with non-struct types. I should add 
a comment.
   
   Checking `is_struct` in this function adds cost in production (where I'm 
assuming Python runs in optimized mode so asserts are disabled). 



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