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: implement when/then/otherwise for DuckDB #1759

Merged
merged 6 commits into from
Jan 8, 2025

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Jan 7, 2025

finally i make a useful today

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

tpch/execute.py Outdated
"dask": lambda x: x.compute(),
}

DUCKDB_XFAILS = [11, 14, 15, 16, 18, 22]
Copy link
Member Author

Choose a reason for hiding this comment

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

16 out of the 22 queries already work with duckdb 😱

@MarcoGorelli MarcoGorelli added the enhancement New feature or request label Jan 7, 2025
@MarcoGorelli MarcoGorelli marked this pull request as ready for review January 7, 2025 20:12
Copy link
Collaborator

@EdAbati EdAbati left a comment

Choose a reason for hiding this comment

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

Looks πŸ‘ŒπŸ‘Œ to me

just added 1 comment about a TypeError that we have in the other backends

@@ -157,6 +158,16 @@ def func(df: DuckDBLazyFrame) -> list[duckdb.Expression]:
kwargs={"exprs": exprs},
)

def when(
self,
*predicates: IntoDuckDBExpr,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
*predicates: IntoDuckDBExpr,
*predicates: IntoDuckDBExpr

trailing comma 😱 (just joking. I love the other PRs πŸ˜…)

Copy link
Member Author

Choose a reason for hiding this comment

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

ok this made me laugh out loud πŸ˜†

*predicates: IntoDuckDBExpr,
) -> DuckDBWhen:
plx = self.__class__(backend_version=self._backend_version, version=self._version)
condition = plx.all_horizontal(*predicates)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
condition = plx.all_horizontal(*predicates)
if predicates:
condition = plx.all_horizontal(*predicates)
else:
msg = "at least one predicate needs to be provided"
raise TypeError(msg)

The other backends have this check

Copy link
Member Author

Choose a reason for hiding this comment

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

ah i moved it up cause i was tired of rewriting it everywhere πŸ˜„ #1756

Copy link
Collaborator

Choose a reason for hiding this comment

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

nice!

@MarcoGorelli MarcoGorelli merged commit 1f0c718 into narwhals-dev:main Jan 8, 2025
23 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