Fix #959: count reports the number of Data Points - #967
Merged
Conversation
albertohernandez1995
enabled auto-merge (squash)
August 4, 2026 11:28
2 tasks
count in a Data Set evaluation applies to each Measure and gives back that same Measure, counted; a lone Measure is renamed to int_var. The Data Set form and the Component form now report the same numbers, and a group that counts no value reports 0 instead of null. count() with no operand still reports the number of Data Points.
Every case in the issue behaves as decided for count, on both engines, so the fixture records them: a Data Set operand counts each Measure and reports 0 for a group holding no value, count() with no operand counts the Data Points, an analytic count reports 0 for a partition of nulls and covers the whole partition where the window clause is omitted, and a having condition keeps the viral attributes.
Every case in the issue behaves as decided for count, on both engines, so the fixture records them: a Data Set operand counts each Measure and reports 0 for a group holding no value, count() with no operand counts the Data Points, an analytic count reports 0 for a partition of nulls and covers the whole partition where the window clause is omitted, and a having condition keeps the viral attributes.
3 tasks
Closed
2 tasks
2 tasks
javihern98
approved these changes
Aug 13, 2026
javihern98
left a comment
Contributor
There was a problem hiding this comment.
Looks good, thanks! 😊
2 tasks
This was referenced Aug 13, 2026
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.
Summary
Applies the meeting decision
on
count, and closes #996 with it: the eight cases reported there were checked against the samedecision, as its comment
asked.
What count does now
COUNT(Me_1) AS Me_1. A Data Set holding a single Measure returns it renamed toint_var.count(DS_1 group by Id_1)andDS_1[aggr n := count(Me_1) group by Id_1]agree.0, not null. The DuckDb transpiler dropped the twoNULLIF(..., 0)wrappers that turned an empty count into null; the pandas engine fills thegroups the aggregation leaves out, after the
havingfilter reads them.count()with no operand still reports the number of Data Points: it is now given no Measuresto count, which also fixes it reporting the first Measure's non-null count on the pandas engine,
and reporting nothing at all when the Data Set is not grouped.
The cases of #996
count(DS_1)0Me_int 9,Me_num 10,Me_str 8count(DS_1 group by Id_1)NA0for an empty group[aggr n := count(Me_int) group by Id_2]NA3, 3, 3, 0[aggr n := count() group by Id_2]NAon pandas3, 3, 3, 1count(Me_int over (partition by Id_2))1on pandas0count(Me_num over (order by Id_2, Id_1))1on pandas10on every rowhaving+ viral attributeKeyErroron pandas3, 3, 3count(Me_str over (partition by Id_2))TypeErroron pandas3, 2, 2, 1Two of them answer differently from what that issue expected, on purpose:
countover a Data Setno longer reports the number of Data Points (cases 1 and 2), and an omitted window clause covers
the whole partition (case 6, #1002). Checking the first of those turned up one more bug, fixed
here:
DS_1 [ aggr n := count() ]with no group clause raisedInvalid Input Error: Need a DataFrame with at least one columnon the pandas engine whileDuckDb answered
10, because an ungroupedcount()is left with no column at all.Checklist
ruff format,ruff check,mypy)pytest, bothduckdbandpandasbackends)Impact / Risk
countover a Data Set no longer reports the number of Data Points:int_var, so[rename int_var to ...]and[keep int_var]stop resolving;wherever the operand holds nulls.
0where they used to return null.DS [ aggr int_var := count ( ) group ... ]or
count ( DS#<identifier> group ... )— an identifier is never null, so both keep the previousnumbers and the
int_varname. Seven test scripts were migrated that way, including the AnaMartand AnaVal projects.
total_records_per_monthinGL_466_1andaggr.numDPCouYearinDEMO1show the effect on real scripts.Notes
GH_959_1covers a Data Set of one Measure,GH_959_2a Data Set of two, andGH_996_1runs thenine cases of #996 over the Data Set of that issue.
GH_980_1pins the analytic count over a partition that holds only a null, which reports 0. Thatwas already fixed by #990 and is not changed here: the fixture is what makes the count rework
answerable for it, since the two engines disagreed on it before (
1on pandas,0on DuckDb) andthe Data Set is the one attached to that issue.
Closes #959
Closes #996
Closes #980