Skip to content

Commit 8b60b8a

Browse files
Automated commit of generated code
1 parent 6fcedc3 commit 8b60b8a

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/add.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,10 @@ public class AddDsl<T>(
320320
add(dsl.columns.toColumnGroup(name))
321321
}
322322

323+
@Interpretable("AddDslAddGroup")
323324
public fun group(body: AddDsl<T>.() -> Unit): AddGroup<T> = AddGroup(body)
324325

326+
@Interpretable("AddDslAddGroupInto")
325327
public infix fun AddGroup<T>.into(groupName: String): Unit = group(groupName, body)
326328

327329
@Deprecated(DEPRECATED_ACCESS_API)

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ public interface TraversePropertiesDsl {
169169
public fun preserve(vararg properties: KCallable<*>)
170170
}
171171

172+
/**
173+
* Store values of given type [T] in ValueColumns without transformation into ColumnGroups or FrameColumns.
174+
*/
175+
@Interpretable("PreserveT")
172176
public inline fun <reified T> TraversePropertiesDsl.preserve(): Unit = preserve(T::class)
173177

174178
public abstract class CreateDataFrameDsl<T> : TraversePropertiesDsl {
@@ -177,8 +181,10 @@ public abstract class CreateDataFrameDsl<T> : TraversePropertiesDsl {
177181

178182
public abstract fun add(column: AnyBaseCol, path: ColumnPath? = null)
179183

184+
@Interpretable("ToDataFrameDslIntoString")
180185
public infix fun AnyBaseCol.into(name: String): Unit = add(this, pathOf(name))
181186

187+
@Interpretable("ToDataFrameDslIntoPath")
182188
public infix fun AnyBaseCol.into(path: ColumnPath): Unit = add(this, path)
183189

184190
@Interpretable("Properties0")
@@ -191,6 +197,7 @@ public abstract class CreateDataFrameDsl<T> : TraversePropertiesDsl {
191197
public inline fun <reified R> expr(infer: Infer = Infer.Nulls, noinline expression: (T) -> R): DataColumn<R> =
192198
source.map { expression(it) }.toColumn(infer = infer)
193199

200+
@Interpretable("ToDataFrameDslAdd")
194201
public inline fun <reified R> add(name: String, noinline expression: (T) -> R): Unit =
195202
add(source.map { expression(it) }.toColumn(name, Infer.Nulls))
196203

@@ -202,6 +209,7 @@ public abstract class CreateDataFrameDsl<T> : TraversePropertiesDsl {
202209
public inline infix fun <reified R> KProperty<R>.from(noinline expression: (T) -> R): Unit =
203210
add(columnName, expression)
204211

212+
@Interpretable("ToDataFrameDslFromInferType")
205213
public inline infix fun <reified R> String.from(inferType: InferType<T, R>): Unit =
206214
add(DataColumn.createByInference(this, source.map { inferType.expression(it) }))
207215

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,25 @@ class CreateDataFrameTests {
167167
df2.a.kind() shouldBe ColumnKind.Group
168168
}
169169

170+
class ExcludeTestData(val s: String, val data: NestedData)
171+
172+
class NestedData(val i: Int, val nestedStr: String)
173+
174+
@Test
175+
fun `preserve T test`() {
176+
val data = listOf(
177+
ExcludeTestData("test", NestedData(42, "nested")),
178+
ExcludeTestData("test2", NestedData(43, "nested2")),
179+
)
180+
181+
val res = data.toDataFrame {
182+
preserve<NestedData>()
183+
properties(maxDepth = 2)
184+
}
185+
186+
res.schema() shouldBe data.toDataFrame(maxDepth = 0).schema()
187+
}
188+
170189
enum class DummyEnum { A }
171190

172191
@Test

0 commit comments

Comments
 (0)