-
Notifications
You must be signed in to change notification settings - Fork 295
feat!: revert daft.func behavior on literal arguments #5087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR reverts changes from #4998 that introduced an explicit eval
method for UDFs (User Defined Functions) decorated with @daft.func
. The revert restores the previous behavior where UDFs automatically detect argument types and execute appropriately: when called with literal arguments (non-Expression objects), they execute immediately and return the actual result; when called with Expression objects, they return a Daft Expression for use in DataFrame operations.
The changes span the UDF module's core implementation and test files. In row_wise.py
and generator.py
, the standalone eval
methods are removed and the eager evaluation logic is restored to the __call__
method using get_expr_args()
to detect if any arguments are Expression objects. When len(expr_args) == 0
, the UDF executes immediately via self._inner(*args, **kwargs)
. Proper type overloads are added to support both return types (T
for eager execution, Expression
for lazy execution).
The test files are updated to remove .eval()
method calls, demonstrating that UDFs now work directly with literal arguments (e.g., my_stringify_and_sum(1, 2)
instead of my_stringify_and_sum.eval(1, 2)
). The docstring in __init__.py
is updated to clarify this dual behavior pattern.
This change integrates with Daft's expression system by maintaining the automatic detection mechanism that allows the same UDF to work seamlessly in both eager Python execution contexts and lazy DataFrame expression contexts, providing better API ergonomics and backward compatibility.
Confidence score: 4/5
- This PR is safe to merge with low risk as it reverts to well-tested previous behavior
- Score reflects straightforward revert with comprehensive test coverage and clear implementation
- Pay attention to UDF implementation files (row_wise.py, generator.py) to ensure overload signatures are correct
5 files reviewed, no comments
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5087 +/- ##
==========================================
+ Coverage 75.27% 76.07% +0.79%
==========================================
Files 949 950 +1
Lines 132520 130512 -2008
==========================================
- Hits 99761 99293 -468
+ Misses 32759 31219 -1540
🚀 New features to boost your workflow:
|
) ## Changes Made Reverts the changes in Eventual-Inc#4998 for v0.6 after further discussion. ## Related Issues <!-- Link to related GitHub issues, e.g., "Closes Eventual-Inc#123" --> ## Checklist - [x] Documented in API Docs (if applicable) - [x] Documented in User Guide (if applicable) - [x] If adding a new documentation page, doc is added to `docs/mkdocs.yml` navigation - [x] Documentation builds and is formatted properly (tag @/ccmao1130 for docs review)
) ## Changes Made Reverts the changes in Eventual-Inc#4998 for v0.6 after further discussion. ## Related Issues <!-- Link to related GitHub issues, e.g., "Closes Eventual-Inc#123" --> ## Checklist - [x] Documented in API Docs (if applicable) - [x] Documented in User Guide (if applicable) - [x] If adding a new documentation page, doc is added to `docs/mkdocs.yml` navigation - [x] Documentation builds and is formatted properly (tag @/ccmao1130 for docs review)
Changes Made
Reverts the changes in #4998 for v0.6 after further discussion.
Related Issues
Checklist
docs/mkdocs.yml
navigation