Skip to content
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: track whether expressions change length but don't aggregate, and only allow length-changing expressions if they're followed by aggregations in the lazy API #1828

Merged
merged 11 commits into from
Jan 20, 2025

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Jan 19, 2025

Getting closer to stable.v2

Similar to #743

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

  • Related issue #<issue number>
  • Closes #<issue number>

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below

Comment on lines +43 to +44
with pytest.raises(LengthChangingExprError):
df.select((nw.col("a").unique() + nw.col("b").unique()).sum())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an expression like this is so bizarre that I doubt we'd be cutting off many real use-cases...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! πŸ˜‚

Copy link
Member

@FBruzzesi FBruzzesi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @MarcoGorelli ! This was easier to go through than expected πŸš€

I left only a couple of comments but I wonder about other edge cases πŸ€”

narwhals/expr_cat.py Outdated Show resolved Hide resolved
narwhals/_expression_parsing.py Outdated Show resolved Hide resolved
Comment on lines +43 to +44
with pytest.raises(LengthChangingExprError):
df.select((nw.col("a").unique() + nw.col("b").unique()).sum())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! πŸ˜‚

tests/expr_and_series/unique_test.py Show resolved Hide resolved
@MarcoGorelli MarcoGorelli marked this pull request as ready for review January 19, 2025 17:02
@MarcoGorelli MarcoGorelli added the enhancement New feature or request label Jan 20, 2025
@MarcoGorelli
Copy link
Member Author

thanks for your review!

@MarcoGorelli MarcoGorelli merged commit b26358b into narwhals-dev:main Jan 20, 2025
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants