-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rename impl fix #1104
rename impl fix #1104
Conversation
return renameImpl { newNames[i++] } | ||
// associate old column names with new ones | ||
val selectedColumns = df.getColumnsWithPaths(columns) | ||
val oldToNew = newNames.mapIndexed { index, newName -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to "associate", there's a function named exactly that ;p maybe you can use it here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need indices here, but there's no associateIndexed
unfortunately xD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withIndex().associate {} works, but then again, this works too :p
// associate old column names with new ones | ||
val selectedColumns = df.getColumnsWithPaths(columns) | ||
val oldToNew = newNames.mapIndexed { index, newName -> | ||
selectedColumns[index].name to newName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can now throw an exception even there are fewer columns selected than names given. If we want to maintain the old behavior, we should limit newNames to the number of selected columns before mapping
selectedColumns[index].name to newName | ||
}.toMap() | ||
|
||
return renameImpl { column -> oldToNew[column.name] ?: column.name } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens for columns with the same name at different paths? Probably create the map by path, not by name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point!
fixes #1067