`replace` should handle selecting both a ColumnGroup and its child
- Dominant language
- Kotlin
- Stars
- 1.1k
- Forks
- 83
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 30
Description
Similar to https://github.com/Kotlin/dataframe/issues/405, also `replace` breaks when running on both a `ColumnGroup` and its child.
Current implementation:
```kotlin
public fun ReplaceClause.with(transform: ColumnsContainer.(DataColumn) -> AnyBaseCol): DataFrame {
val removeResult = df.removeImpl(columns = columns)
// removeResult.removedColumns contains the removed columns, but only the roots, so `group.child` is not
// included, just `group`, meaning `transform` will not be called on `child`
val toInsert = removeResult.removedColumns.map {
val newCol = transform(df, it.data.column as DataColumn)
// pathFromRoot() returns the original path with a name change
// will be incorrect if one of its parents had a rename
ColumnToInsert(it.pathFromRoot().dropLast(1) + newCol.name, newCol, it)
}
return removeResult.df.insertImpl(toInsert)
}
```
Contributor guide
Research direction
Start at ReplaceClause.with and trace removeImpl and insertImpl, comparing the related issue 405. Verify that selecting both a ColumnGroup and its child applies the transform to the child and preserves the correct path when a parent is renamed; the issue is done when replacement works for both selections.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100