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


##########
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:
   Something has been bothering me about these functions and I think I finally 
identified it today. It feels like these are LLM generated naming and approach. 
I don't know if you're using a LLM or hand writing these, but the naming feels 
like it obfuscates the intent.
   
   Would you mind if I took a stab at rewriting some of these to be more 
consistent with the existing code base and what I think conveys meaning a 
little clearer?



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