feat(expressions): support count(mode='all') without expr#6358
Open
Abyss-lord wants to merge 1 commit intoEventual-Inc:mainfrom
Open
feat(expressions): support count(mode='all') without expr#6358Abyss-lord wants to merge 1 commit intoEventual-Inc:mainfrom
Abyss-lord wants to merge 1 commit intoEventual-Inc:mainfrom
Conversation
Contributor
Greptile SummaryThis PR extends Key changes:
The implementation is straightforward, with tests demonstrating correct behavior across various partition configurations and edge cases including empty DataFrames. Confidence Score: 4/5
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["count(expr=None, mode=CountMode.Valid)"] --> B{is mode a string?}
B -- yes --> C["mode = CountMode.from_count_mode_str(mode)"]
B -- no --> D{expr is None?}
C --> D
D -- no --> G["Expression._from_pyexpr(expr._expr.count(mode))"]
D -- yes --> E{mode == CountMode.All?}
E -- no --> F["raise ValueError('count() without an expression\nonly supports mode=all')"]
E -- yes --> H["expr = col('*')"]
H --> G
G --> I["return Expression"]
Last reviewed commit: 5a4da66 |
Contributor
Author
|
@rchowell @universalmind303 could you please review this PR when you have time? I’d really appreciate your feedback. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes Made
This PR adds support for calling
daft.functions.count(mode="all")without passing an expression, enabling free-standing row-count aggregations similar to SQLCOUNT(*).What changed
daft.functions.countindaft/functions/agg.pyto accept an optionalexprargument.expr=None:mode="all"is allowed and maps tocount(*)semantics viacol("*").mode="valid"ormode="null"now raises a clearValueErrorwhen no expression is provided.count(expr, mode=...)andcount(lit(...))usages.Tests added
In
tests/dataframe/test_aggregations.py:count(mode="all")and no expression.count(mode="all")and no expression.0result).allmodes.Validation run
DAFT_RUNNER=native make test EXTRA_ARGS="-v tests/dataframe/test_aggregations.py"DAFT_RUNNER=native make test EXTRA_ARGS="-v tests/sql/test_sql.py tests/sql/test_exprs.py"Related Issues
Closes #5526