BharatDeva opened a new pull request, #1642:
URL: https://github.com/apache/datafusion-python/pull/1642

   # Which issue does this PR close?
   
   Closes #1507.
   
   # Rationale for this change
   
   The scalar UDF helper currently uses the same type variable for the Python 
callable return value and the declared Arrow return field. Those are different 
concepts: the callable returns Arrow arrays, while `return_field` can be an 
Arrow data type or field used to declare the UDF output.
   
   Keeping those hints separate makes the public wrapper easier to use from 
type checkers and avoids implying that callers should pass an array object as 
the return field.
   
   # What changes are included in this PR?
   
   This PR tightens the scalar UDF annotations in 
`python/datafusion/user_defined.py`:
   
   - the callable return type is bounded to `pa.Array`
   - the scalar UDF constructor accepts `return_field: pa.Field`
   - the decorator form accepts `return_field: pa.DataType | pa.Field`
   
   # Are there any user-facing changes?
   
   No runtime behavior changes. This only updates Python type hints for the 
scalar UDF wrapper.
   
   Validation run locally:
   
   - `uvx [email protected] check python/datafusion/user_defined.py` - passed
   - `uvx [email protected] format --check python/datafusion/user_defined.py` - passed
   - `git diff --check origin/main...HEAD` - passed


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