File tree Expand file tree Collapse file tree 4 files changed +19
-0
lines changed
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api
src/org/jetbrains/kotlinx/dataframe/plugin Expand file tree Collapse file tree 4 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,7 @@ public class AddDsl<T>(
225225 @AccessApiOverload
226226 public fun group (column : AnyColumnGroupAccessor , body : AddDsl <T >.() -> Unit ): Unit = group(column.name(), body)
227227
228+ @Interpretable(" AddDslNamedGroup" )
228229 public fun group (name : String , body : AddDsl <T >.() -> Unit ) {
229230 val dsl = AddDsl (df)
230231 body(dsl)
Original file line number Diff line number Diff line change @@ -68,3 +68,15 @@ class AddDslStringInvoke : AbstractInterpreter<Unit>() {
6868 dsl.columns.add(SimpleColumnGroup (receiver, addDsl.columns))
6969 }
7070}
71+
72+ class AddDslNamedGroup : AbstractInterpreter <Unit >() {
73+ val Arguments .dsl: AddDslApproximation by arg()
74+ val Arguments .name: String by arg()
75+ val Arguments .body by dsl()
76+
77+ override fun Arguments.interpret () {
78+ val addDsl = AddDslApproximation (mutableListOf ())
79+ body(addDsl, emptyMap())
80+ dsl.columns.add(SimpleColumnGroup (name, addDsl.columns))
81+ }
82+ }
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ import org.jetbrains.kotlin.name.CallableId
7171import org.jetbrains.kotlin.name.ClassId
7272import org.jetbrains.kotlin.name.Name
7373import org.jetbrains.kotlin.name.StandardClassIds
74+ import org.jetbrains.kotlinx.dataframe.plugin.impl.api.AddDslNamedGroup
7475import org.jetbrains.kotlinx.dataframe.plugin.impl.api.AddDslStringInvoke
7576import org.jetbrains.kotlinx.dataframe.plugin.impl.api.AddId
7677import org.jetbrains.kotlinx.dataframe.plugin.impl.api.Aggregate
@@ -255,6 +256,7 @@ internal inline fun <reified T> String.load(): T {
255256 " FlattenDefault" -> FlattenDefault ()
256257 " AddId" -> AddId ()
257258 " AddDslStringInvoke" -> AddDslStringInvoke ()
259+ " AddDslNamedGroup" -> AddDslNamedGroup ()
258260 " MapToFrame" -> MapToFrame ()
259261 " Move0" -> Move0 ()
260262 " ToTop" -> ToTop ()
Original file line number Diff line number Diff line change @@ -9,8 +9,12 @@ fun box(): String {
99 " group" {
1010 " a" from { it }
1111 }
12+ group(" group1" ) {
13+ " b" from { it }
14+ }
1215 }
1316
1417 df.group.a
18+ df.group1.b
1519 return " OK"
1620}
You can’t perform that action at this time.
0 commit comments