-
Notifications
You must be signed in to change notification settings - Fork 72
Row UDF scalar arguments #311
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
Row UDF scalar arguments #311
Conversation
|
This is ready for review - I thought some code might need to be written to disambiguate when one has a column with a name that could also be a constant, like having a column with name |
ayushdg
left a comment
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.
Thanks a lot for the changes @brandon-b-miller !
Couple of minor comments in addition to the changes suggested:
Would it be possible to also update the docstring to include an example with scalar values?
Also I was able to catch the issues below while testing this with udfs that accept multiple column args, since in the single arg case the output would be correct. Might be worth adding that case to the tests as well.
dask_sql/datacontainer.py
Outdated
| scalar_args.append(operand) | ||
| df = column_args[0].to_frame() | ||
| for col in column_args[1:]: | ||
| df[col.name] = operand |
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.
| df[col.name] = operand | |
| df[col.name] = col |
dask_sql/datacontainer.py
Outdated
| df = column_args[0].to_frame() | ||
| for col in column_args[1:]: | ||
| df[col.name] = operand |
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.
I'm guessing this section was meant to be outside the loop.
|
Updated! :) |
charlesbluca
left a comment
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.
Thanks for the work here @brandon-b-miller 🙂 just small nitpicks, the code itself LGTM
tests/integration/test_function.py
Outdated
| assert_frame_equal(return_df.reset_index(drop=True), expectation) | ||
|
|
||
|
|
||
| # Test row UDFs with one args |
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.
| # Test row UDFs with one args | |
| # Test row UDFs with two args |
tests/integration/test_function.py
Outdated
| assert_frame_equal(return_df.reset_index(drop=True), expectation) | ||
|
|
||
|
|
||
| # Test row UDFs with one args |
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.
| # Test row UDFs with one args | |
| # Test row UDFs with one arg |
ayushdg
left a comment
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.
One small suggestion otherwise lgtm!
dask_sql/datacontainer.py
Outdated
| column_args.append(operand) | ||
| else: | ||
| scalar_args.append(operand) | ||
| df = column_args[0].to_frame() |
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.
| df = column_args[0].to_frame() | |
| df = column_args[0].to_frame() |
Codecov Report
@@ Coverage Diff @@
## main #311 +/- ##
==========================================
- Coverage 95.75% 95.69% -0.06%
==========================================
Files 65 65
Lines 2802 2810 +8
Branches 418 421 +3
==========================================
+ Hits 2683 2689 +6
- Misses 77 78 +1
- Partials 42 43 +1
Continue to review full report at Codecov.
|
charlesbluca
left a comment
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.
LGTM; thanks for the work @brandon-b-miller 😄
Closes #279