Skip to content

Commit 64f495a

Browse files
committed
[Compiler plugin] Support DF operations in AggregateGroupedBody scope
1 parent e9f6ea0 commit 64f495a

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
package org.jetbrains.kotlinx.dataframe.aggregation
22

3+
import org.jetbrains.kotlinx.dataframe.annotations.HasSchema
4+
5+
@HasSchema(schemaArg = 0)
36
public abstract class AggregateGroupedDsl<out T> : AggregateDsl<T>()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import org.jetbrains.kotlinx.dataframe.*
2+
import org.jetbrains.kotlinx.dataframe.annotations.*
3+
import org.jetbrains.kotlinx.dataframe.api.*
4+
import org.jetbrains.kotlinx.dataframe.api.toDataFrame
5+
import org.jetbrains.kotlinx.dataframe.io.*
6+
7+
data class Name(val firstName: String, val lastName: String)
8+
9+
data class Score(val subject: String, val value: Int)
10+
11+
data class Student(val name: Name, val age: Int, val scores: List<Score>)
12+
13+
fun box(): String {
14+
val students = listOf(
15+
Student(Name("Alice", "Cooper"), 15, listOf(Score("math", 4), Score("biology", 3))),
16+
Student(Name("Bob", "Marley"), 20, listOf(Score("music", 5))),
17+
)
18+
19+
val df = students.toDataFrame().groupBy { expr { name.firstName} }
20+
.aggregate {
21+
remove { age } into "a"
22+
}
23+
24+
df.compareSchemas(strict = true)
25+
return "OK"
26+
}

plugins/kotlin-dataframe/tests-gen/org/jetbrains/kotlin/fir/dataframe/DataFrameBlackBoxCodegenTestGenerated.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,12 @@ public void testMapToFrame() {
292292
runTest("testData/box/mapToFrame.kt");
293293
}
294294

295+
@Test
296+
@TestMetadata("modifySchemaInAggregate.kt")
297+
public void testModifySchemaInAggregate() {
298+
runTest("testData/box/modifySchemaInAggregate.kt");
299+
}
300+
295301
@Test
296302
@TestMetadata("moveAfter.kt")
297303
public void testMoveAfter() {

0 commit comments

Comments
 (0)