kosiew commented on code in PR #1287:
URL: 
https://github.com/apache/datafusion-python/pull/1287#discussion_r2492816436


##########
python/datafusion/user_defined.py:
##########
@@ -77,6 +101,87 @@ def __str__(self) -> str:
         return self.name.lower()
 
 
+def _clone_field(field: pa.Field) -> pa.Field:
+    """Return a deep copy of ``field`` including its DataType."""
+    return pa.schema([field]).field(0)
+
+
+def _normalize_field(value: pa.DataType | pa.Field, *, default_name: str) -> 
pa.Field:
+    if isinstance(value, pa.Field):
+        return _clone_field(value)
+    if isinstance(value, pa.DataType):
+        return _clone_field(pa.field(default_name, value))
+    msg = "Expected a pyarrow.DataType or pyarrow.Field"
+    raise TypeError(msg)

Review Comment:
   Not at all.



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