From 9697092a5084f35d9e1912044f823ff9622474ee Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Sun, 26 Jan 2025 12:57:31 +0100 Subject: [PATCH] creating compiler-plugin support for renameToCamelCase.kt --- .../jetbrains/kotlinx/dataframe/api/rename.kt | 2 ++ .../testData/box/renameToCamelCase.kt | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 plugins/kotlin-dataframe/testData/box/renameToCamelCase.kt diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt index 76744bbe43..d04bd991f3 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt @@ -52,6 +52,8 @@ public class RenameClause(internal val df: DataFrame, internal val colu * and converting the first char to lowercase. * Even [DataFrames][DataFrame] inside [FrameColumns][FrameColumn] are traversed recursively. */ +@Refine +@Interpretable("RenameToCamelCase") public fun DataFrame.renameToCamelCase(): DataFrame = // recursively rename all columns written with delimiters or starting with a capital to camel case rename { diff --git a/plugins/kotlin-dataframe/testData/box/renameToCamelCase.kt b/plugins/kotlin-dataframe/testData/box/renameToCamelCase.kt new file mode 100644 index 0000000000..58bfdec70c --- /dev/null +++ b/plugins/kotlin-dataframe/testData/box/renameToCamelCase.kt @@ -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" +}