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: add DuckDB join_asof #1860

Merged
merged 8 commits into from
Jan 24, 2025

Conversation

raisadz
Copy link
Contributor

@raisadz raisadz commented Jan 24, 2025

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

  • 💾 Refactor
  • ✨ Feature
  • 🐛 Bug Fix
  • 🔧 Optimization
  • 📝 Documentation
  • ✅ Test
  • 🐳 Other

Related issues

Checklist

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

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

@raisadz raisadz changed the title feat: add DuckDB joinasof feat: add DuckDB join_asof Jan 24, 2025
@raisadz raisadz marked this pull request as ready for review January 24, 2025 08:09
@FBruzzesi FBruzzesi added enhancement New feature or request duckdb Issue is related to duckdb backend labels Jan 24, 2025
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

amazing, thanks so much! just some minor comments

strategy: Literal["backward", "forward", "nearest"],
suffix: str = "_right",
Copy link
Member

Choose a reason for hiding this comment

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

really minor, but can we avoid setting the default in the compliant level? So, in narwhals.dataframe.py, we can have suffix: str = "_right", but in the internal methods in _arrow / _duckdb / _pandas_like / etc., we can just have suffix: str, to make sure that we're always passing it down?

strategy: Literal["backward", "forward", "nearest"] = "backward",
suffix: str = "_right",
) -> Self:
import duckdb
Copy link
Member

Choose a reason for hiding this comment

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

i think we can do this at the top of the file

msg = "Only 'backward' and 'forward' strategies are currently supported for DuckDB"
raise NotImplementedError(msg)
condition = " and ".join(conditions)
select = [f'lhs."{x}"' for x in lhs.columns]
Copy link
Member

Choose a reason for hiding this comment

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

🤔 does `select = ['lhs.*'] work?

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 for the PR @raisadz 🙌🏼

As a tiny nitpick: since you moved the parsing logic at DataFrame level, it would be good to remove the argument default values in the compliant implementation

Copy link
Member

Choose a reason for hiding this comment

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

Nice one! 👌

Copy link
Member

Choose a reason for hiding this comment

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

Amazing work here as well 🎻

@raisadz
Copy link
Contributor Author

raisadz commented Jan 24, 2025

Thank you @MarcoGorelli and @FBruzzesi for your reviews! I addressed your comments

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

thanks @raisadz !

@MarcoGorelli MarcoGorelli merged commit 05cb650 into narwhals-dev:main Jan 24, 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
duckdb Issue is related to duckdb backend enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants