-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat(python): Add post-optimization callback #15972
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #15972 +/- ##
==========================================
+ Coverage 80.89% 80.95% +0.06%
==========================================
Files 1384 1384
Lines 178020 178106 +86
Branches 3043 3043
==========================================
+ Hits 144003 144183 +180
+ Misses 33535 33440 -95
- Partials 482 483 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
// Pass the node visitor which allows the python callback to replace parts of the query plan. | ||
// Remove "cuda" or specify better once we have multiple post-opt callbacks. | ||
lambda.call1(py, (nt,)).map_err( | ||
|e| polars_err!(ComputeError: "'cuda' conversion failed: {}", e), | ||
)?; |
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.
OK so the contract here is that the callback should modify the NodeTraverser
via set_udf
to substitute in the subtree it can execute. But that callback isn't allowed to hold on to the NodeTraverser
, since when the callback actually runs the arenas inside it are garbage.
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.
Indeed. Any state that needs to be preserved should be in the callback itself.
This allows a post-optimization python callback to be inserted.