Skip to content

[data] move _munge_conflict to parent class - #46668

Merged
richardliaw merged 7 commits into
ray-project:masterfrom
KPostOffice:munge-table
Dec 5, 2024
Merged

richardliaw merged 7 commits into
ray-project:masterfrom
KPostOffice:munge-table

Conversation

@KPostOffice

@KPostOffice KPostOffice commented Jul 16, 2024 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

PandaDataAccessor does not have function _munge_conflict

Related issue number

closes: #46275

Checks

@anyscalesam anyscalesam added triage Needs triage (eg: priority, bug/not-bug, and owning component) data Ray Data-related issues labels Jul 29, 2024

@c21 c21 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the fix!

@c21 c21 added go add ONLY when ready to merge, run all tests and removed triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Aug 7, 2024
@richardliaw richardliaw changed the title move _munge_conflict to parent class [data] move _munge_conflict to parent class Dec 5, 2024
@richardliaw
richardliaw merged commit 2f0e79b into ray-project:master Dec 5, 2024
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Dec 17, 2024
## Why are these changes needed?

PandaDataAccessor does not have function _munge_conflict

## Related issue number

closes: ray-project#46275

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [ ] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

Signed-off-by: Kevin <[email protected]>
Co-authored-by: Cheng Su <[email protected]>
Signed-off-by: ujjawal-khare <[email protected]>
goutamvenkat-anyscale pushed a commit that referenced this pull request Sep 18, 2026
…names (#66218)

## Why

Two bugs in `TableBlockAccessor`'s aggregation path, both visible from
the public API.

**A global aggregation over an empty dataset returns `None`.**

```python
ray.data.range(10).filter(lambda row: False).aggregate(Count())
# before: None
# after:  {'count()': 0}
```

#66194 added an early return for zero-row blocks. That is right for a
keyed aggregation — no rows means no groups — but a global aggregation
always has exactly one group, and still owes its identity row. Counting
an empty dataset is `0`, not "no answer".

**Repeated aggregations overwrite each other's results.**

```python
ray.data.range(4).aggregate(Sum("id"), Sum("id"), Sum("id"))
# before: {'sum(id)': 6, 'sum(id)_2': 6}
# after:  {'sum(id)': 6, 'sum(id)_2': 6, 'sum(id)_3': 6}
```

`_resolve_aggregated_column_names` suffixes duplicate names, but
incremented the counter for the *suffixed* name rather than the
original. The original's count never advanced past one, so every
duplicate after the first resolved to `_2` again. Because `_aggregate`
builds rows with `row[name] = accumulator`, two aggregations sharing a
name means one result is silently dropped.

## What changes

- The empty-block early return in `_aggregate` is gated on there being
group keys, and the `num_rows() > 0` check around `accumulate_block` is
restored, so an empty group leaves the accumulators at their identity
values.
- `_resolve_aggregated_column_names` counts the original name and
suffixes until the name is free. Looping rather than suffixing once also
covers a generated suffix colliding with an aggregation explicitly named
that, as in `["a", "a_2", "a"]`. It now takes the names rather than the
aggregations, since that is all it reads.
- `GPUAggregationPlan` carried its own copy of that loop, which resolved
names differently from the CPU path — the same query returned different
column names depending on the shuffle strategy. It now calls the shared
helper.
- Tests for both bugs in `test_dataset_aggregrations.py`.

The name-collision bug predates #66194 — it dates to #20044 and survived
#46668 and #50498; #66194 only lifted the loop into a helper, which is
why `git blame` points there.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Aarrya <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…names (ray-project#66218)

## Why

Two bugs in `TableBlockAccessor`'s aggregation path, both visible from
the public API.

**A global aggregation over an empty dataset returns `None`.**

```python
ray.data.range(10).filter(lambda row: False).aggregate(Count())
# before: None
# after:  {'count()': 0}
```

ray-project#66194 added an early return for zero-row blocks. That is right for a
keyed aggregation — no rows means no groups — but a global aggregation
always has exactly one group, and still owes its identity row. Counting
an empty dataset is `0`, not "no answer".

**Repeated aggregations overwrite each other's results.**

```python
ray.data.range(4).aggregate(Sum("id"), Sum("id"), Sum("id"))
# before: {'sum(id)': 6, 'sum(id)_2': 6}
# after:  {'sum(id)': 6, 'sum(id)_2': 6, 'sum(id)_3': 6}
```

`_resolve_aggregated_column_names` suffixes duplicate names, but
incremented the counter for the *suffixed* name rather than the
original. The original's count never advanced past one, so every
duplicate after the first resolved to `_2` again. Because `_aggregate`
builds rows with `row[name] = accumulator`, two aggregations sharing a
name means one result is silently dropped.

## What changes

- The empty-block early return in `_aggregate` is gated on there being
group keys, and the `num_rows() > 0` check around `accumulate_block` is
restored, so an empty group leaves the accumulators at their identity
values.
- `_resolve_aggregated_column_names` counts the original name and
suffixes until the name is free. Looping rather than suffixing once also
covers a generated suffix colliding with an aggregation explicitly named
that, as in `["a", "a_2", "a"]`. It now takes the names rather than the
aggregations, since that is all it reads.
- `GPUAggregationPlan` carried its own copy of that loop, which resolved
names differently from the CPU path — the same query returned different
column names depending on the shuffle strategy. It now calls the shared
helper.
- Tests for both bugs in `test_dataset_aggregrations.py`.

The name-collision bug predates ray-project#66194 — it dates to ray-project#20044 and survived
ray-project#46668 and ray-project#50498; ray-project#66194 only lifted the loop into a helper, which is
why `git blame` points there.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Aarrya <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data: PandasBlockAccessor does not have the attribute _munge_conflict

4 participants