File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,23 @@ import org.jetbrains.kotlinx.dataframe.impl.columns.tree.map
1515import org.jetbrains.kotlinx.dataframe.kind
1616
1717internal fun <T , C > RenameClause <T , C >.renameImpl (newNames : Array <out String >): DataFrame <T > {
18- // associate old column names with new ones
1918 val selectedColumns = df.getColumnsWithPaths(columns)
19+
20+ if (selectedColumns.size != newNames.size) {
21+ throw IllegalArgumentException (
22+ " Selected column count (${selectedColumns.size} ) must match new " +
23+ " column names count (${newNames.size} )." ,
24+ )
25+ }
26+
27+ // associate old column names with new ones
2028 val oldToNew = newNames.mapIndexed { index, newName ->
21- selectedColumns[index].name to newName
29+ selectedColumns[index].path to newName
2230 }.toMap()
2331
24- return renameImpl { column -> oldToNew[column.name] ? : column.name }
32+ return renameImpl { column ->
33+ oldToNew[column.path] ? : throw IllegalArgumentException (" Unexpected column: $column " )
34+ }
2535}
2636
2737internal fun <T , C > RenameClause <T , C >.renameImpl (transform : (ColumnWithPath <C >) -> String ): DataFrame <T > {
You can’t perform that action at this time.
0 commit comments