Generate unique names for multiple unnamed expression columns in `groupBy`
- Dominant language
- Kotlin
- Stars
- 1.1k
- Forks
- 83
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 30
Description
Cannot groupBy multiple unnamed expression columns:
```kt
dataFrameOf("a", "b")(1, 2)
.groupBy { expr { "a"() + 1 } and expr { "b"() - 1 } }
```
results in an exception
```
Can not insert more than one column into the path []
java.lang.IllegalStateException: Can not insert more than one column into the path []
```
Seems that `groupBy` doesn't find unique names for unnamed columns, like `DataFrameImpl.init` does.
------------------------------ Added later -----------------------------------------------------------------------
## Problem
`groupBy` fails when several unnamed expression columns are selected as grouping keys.
Example:
```kotlin
dataFrameOf("a", "b")(1, 2)
.groupBy {
expr { "a"() + 1 } and
expr { "b"() - 1 }
}
```
Current result:
```text
Can not insert more than one column into the path []
java.lang.IllegalStateException: Can not insert more than one column into the path []
```
The issue seems to be that `groupBy` does not assign unique generated names to multiple unnamed expression columns. This differs from `DataFrameImpl.init`, which can generate unique names for unnamed columns.
## Expected Behavior
`groupBy` should either:
- generate stable unique names for multiple unnamed expression columns, consistently with other DataFrame construction paths; or
- report a clear error telling the user to name the expression columns explicitly.
Silent collision on the empty path should not happen.
## Workaround
Name expression columns explicitly, if the current API supports it:
```kotlin
dataFrameOf("a", "b")(1, 2)
.groupBy {
expr("a_plus_one") { "a"() + 1 } and
expr("b_minus_one") { "b"() - 1 }
}
```
## Definition of Done
- Add a regression test for `groupBy` with two unnamed expression columns.
- Decide whether unnamed grouping expressions should be auto-named or rejected.
- If auto-named:
- generated names are unique and stable;
- behavior is consistent with existing unnamed-column naming rules where possible.
- If rejected:
- the error message clearly explains that multiple unnamed grouping expressions need explicit names.
- Add or adjust tests for:
- one unnamed expression column;
- multiple unnamed expression columns;
- a mix of named and unnamed expression columns;
- no regression for normal named-column grouping.
- Avoid public API changes unless strictly necessary.
Contributor guide
Research direction
Start at the groupBy handling for expression columns and compare its unnamed-column behavior with DataFrameImpl.init. Add regression coverage for one, multiple, and mixed named and unnamed grouping expressions, plus normal named-column grouping. Done means stable unique names or a clear explicit-naming error, with no empty-path collision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100