-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Compiler plugin] Support DF operations in AggregateGroupedBody scope
- Loading branch information
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aggregation/AggregateGroupedDsl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package org.jetbrains.kotlinx.dataframe.aggregation | ||
|
||
import org.jetbrains.kotlinx.dataframe.annotations.HasSchema | ||
|
||
@HasSchema(schemaArg = 0) | ||
public abstract class AggregateGroupedDsl<out T> : AggregateDsl<T>() |
26 changes: 26 additions & 0 deletions
26
plugins/kotlin-dataframe/testData/box/modifySchemaInAggregate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import org.jetbrains.kotlinx.dataframe.* | ||
import org.jetbrains.kotlinx.dataframe.annotations.* | ||
import org.jetbrains.kotlinx.dataframe.api.* | ||
import org.jetbrains.kotlinx.dataframe.api.toDataFrame | ||
import org.jetbrains.kotlinx.dataframe.io.* | ||
|
||
data class Name(val firstName: String, val lastName: String) | ||
|
||
data class Score(val subject: String, val value: Int) | ||
|
||
data class Student(val name: Name, val age: Int, val scores: List<Score>) | ||
|
||
fun box(): String { | ||
val students = listOf( | ||
Student(Name("Alice", "Cooper"), 15, listOf(Score("math", 4), Score("biology", 3))), | ||
Student(Name("Bob", "Marley"), 20, listOf(Score("music", 5))), | ||
) | ||
|
||
val df = students.toDataFrame().groupBy { expr { name.firstName} } | ||
.aggregate { | ||
remove { age } into "a" | ||
} | ||
|
||
df.compareSchemas(strict = true) | ||
return "OK" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters