-
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 groupBy.[first | last | maxBy | minBy].into…
…(columName)
- Loading branch information
Showing
12 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
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
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
35 changes: 35 additions & 0 deletions
35
...ns/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/ReducedGroupBy.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,35 @@ | ||
package org.jetbrains.kotlinx.dataframe.plugin.impl.api | ||
|
||
import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractInterpreter | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractSchemaModificationInterpreter | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.Arguments | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.PluginDataFrameSchema | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleColumnGroup | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.groupBy | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.ignore | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.makeNullable | ||
|
||
class GroupByReducePredicate : AbstractInterpreter<GroupBy>() { | ||
val Arguments.receiver by groupBy() | ||
val Arguments.predicate by ignore() | ||
override fun Arguments.interpret(): GroupBy { | ||
return receiver | ||
} | ||
} | ||
|
||
class GroupByReduceExpression : AbstractInterpreter<GroupBy>() { | ||
val Arguments.receiver by groupBy() | ||
val Arguments.rowExpression by ignore() | ||
override fun Arguments.interpret(): GroupBy { | ||
return receiver | ||
} | ||
} | ||
|
||
class GroupByReduceInto : AbstractSchemaModificationInterpreter() { | ||
val Arguments.receiver by groupBy() | ||
val Arguments.columnName: String by arg() | ||
override fun Arguments.interpret(): PluginDataFrameSchema { | ||
val group = makeNullable(SimpleColumnGroup(columnName, receiver.groups.columns())) | ||
return PluginDataFrameSchema(receiver.keys.columns() + group) | ||
} | ||
} |
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
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
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
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,16 @@ | ||
import org.jetbrains.kotlinx.dataframe.* | ||
import org.jetbrains.kotlinx.dataframe.annotations.* | ||
import org.jetbrains.kotlinx.dataframe.api.* | ||
import org.jetbrains.kotlinx.dataframe.io.* | ||
|
||
fun box(): String { | ||
val groupBy = dataFrameOf("a")(1, 1, 2, 3, 3).groupBy { a }.add("id") { index() } | ||
groupBy.maxBy { id }.into("group").compareSchemas() | ||
groupBy.maxBy { id }.into("group").compareSchemas() | ||
groupBy.first { id == 1 }.into("group").compareSchemas() | ||
groupBy.first().into("group").compareSchemas() | ||
groupBy.last { id == 1 }.into("group").compareSchemas() | ||
groupBy.last().into("group").compareSchemas() | ||
groupBy.minBy { id == 1 }.into("group").compareSchemas() | ||
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