Skip to content

Commit

Permalink
creating compiler-plugin support for renameToCamelCase.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolanrensen committed Jan 26, 2025
1 parent e9e96bc commit 9697092
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class RenameClause<T, C>(internal val df: DataFrame<T>, internal val colu
* and converting the first char to lowercase.
* Even [DataFrames][DataFrame] inside [FrameColumns][FrameColumn] are traversed recursively.
*/
@Refine
@Interpretable("RenameToCamelCase")
public fun <T> DataFrame<T>.renameToCamelCase(): DataFrame<T> =
// recursively rename all columns written with delimiters or starting with a capital to camel case
rename {
Expand Down
16 changes: 16 additions & 0 deletions plugins/kotlin-dataframe/testData/box/renameToCamelCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import org.jetbrains.kotlinx.dataframe.*
import org.jetbrains.kotlinx.dataframe.annotations.*
import org.jetbrains.kotlinx.dataframe.api.*
import org.jetbrains.kotlinx.dataframe.io.*

data class Nested(val some_double: Double)

data class Record(val my_user: String, val age: Int, val nested_type: Nested)

fun box(): String {
val df = listOf(Record("112", 42, Nested(3.0))).toDataFrame(maxDepth = 1)
val df1 = df.renameToCamelCase()
df1.nestedType.someDouble
df1.myUser
return "OK"
}

0 comments on commit 9697092

Please sign in to comment.