-
Notifications
You must be signed in to change notification settings - Fork 71
Fix use of row UDFs at intermediate query stages #409
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
Merged
charlesbluca
merged 6 commits into
dask-contrib:main
from
brandon-b-miller:fix-udf-column-names
Mar 1, 2022
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8919fc0
retain original input names and transform to them later
brandon-b-miller 7787d11
adjust impl
brandon-b-miller 6aa08cd
tests and updates
brandon-b-miller cf7b183
fix tests
brandon-b-miller f2ce42f
Address reviews, fix tests
brandon-b-miller ee0c520
update docs
brandon-b-miller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,7 +183,7 @@ def assign(self) -> dd.DataFrame: | |
|
|
||
|
|
||
| class UDF: | ||
| def __init__(self, func, row_udf: bool, return_type=None): | ||
| def __init__(self, func, row_udf: bool, params, return_type=None): | ||
| """ | ||
| Helper class that handles different types of UDFs and manages | ||
| how they should be mapped to dask operations. Two versions of | ||
|
|
@@ -196,6 +196,8 @@ def __init__(self, func, row_udf: bool, return_type=None): | |
| self.row_udf = row_udf | ||
| self.func = func | ||
|
|
||
| self.names = [param[0] for param in params] | ||
|
|
||
| if return_type is None: | ||
| # These UDFs go through apply and without providing | ||
| # a return type, dask will attempt to guess it, and | ||
|
|
@@ -212,9 +214,11 @@ def __call__(self, *args, **kwargs): | |
| column_args.append(operand) | ||
| else: | ||
| scalar_args.append(operand) | ||
|
|
||
| df = column_args[0].to_frame() | ||
| for col in column_args[1:]: | ||
| df[col.name] = col | ||
| for name, col in zip(self.names, column_args): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we pass the first parameter column name to
charlesbluca marked this conversation as resolved.
Outdated
|
||
| df[name] = col | ||
|
|
||
| result = df.apply( | ||
| self.func, axis=1, args=tuple(scalar_args), meta=self.meta | ||
| ).astype(self.meta[1]) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.