diff --git a/core/api/core.api b/core/api/core.api index 4f7f9ea0c6..332e1ed34f 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -6003,16 +6003,23 @@ public final class org/jetbrains/kotlinx/dataframe/api/Merge { } public final class org/jetbrains/kotlinx/dataframe/api/MergeKt { - public static final fun asStrings (Lorg/jetbrains/kotlinx/dataframe/api/Merge;)Lorg/jetbrains/kotlinx/dataframe/api/Merge; - public static final fun by (Lorg/jetbrains/kotlinx/dataframe/api/Merge;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;)Lorg/jetbrains/kotlinx/dataframe/api/Merge; - public static synthetic fun by$default (Lorg/jetbrains/kotlinx/dataframe/api/Merge;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/api/Merge; + public static final fun asStrings (Lorg/jetbrains/kotlinx/dataframe/api/Merge;)Lorg/jetbrains/kotlinx/dataframe/api/MergeWithTransform; + public static final fun by (Lorg/jetbrains/kotlinx/dataframe/api/Merge;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;)Lorg/jetbrains/kotlinx/dataframe/api/MergeWithTransform; + public static synthetic fun by$default (Lorg/jetbrains/kotlinx/dataframe/api/Merge;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/api/MergeWithTransform; public static final fun into (Lorg/jetbrains/kotlinx/dataframe/api/Merge;Ljava/lang/String;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; - public static final fun into (Lorg/jetbrains/kotlinx/dataframe/api/Merge;Lorg/jetbrains/kotlinx/dataframe/columns/ColumnAccessor;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun into (Lorg/jetbrains/kotlinx/dataframe/api/Merge;Lorg/jetbrains/kotlinx/dataframe/columns/ColumnPath;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun into (Lorg/jetbrains/kotlinx/dataframe/api/MergeWithTransform;Ljava/lang/String;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun into (Lorg/jetbrains/kotlinx/dataframe/api/MergeWithTransform;Lorg/jetbrains/kotlinx/dataframe/columns/ColumnPath;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun intoList (Lorg/jetbrains/kotlinx/dataframe/api/Merge;)Ljava/util/List; + public static final fun intoList (Lorg/jetbrains/kotlinx/dataframe/api/MergeWithTransform;)Ljava/util/List; public static final fun merge (Lorg/jetbrains/kotlinx/dataframe/DataFrame;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/kotlinx/dataframe/api/Merge; public static final fun merge (Lorg/jetbrains/kotlinx/dataframe/DataFrame;[Ljava/lang/String;)Lorg/jetbrains/kotlinx/dataframe/api/Merge; public static final fun notNull (Lorg/jetbrains/kotlinx/dataframe/api/Merge;)Lorg/jetbrains/kotlinx/dataframe/api/Merge; + public static final fun notNullList (Lorg/jetbrains/kotlinx/dataframe/api/Merge;)Lorg/jetbrains/kotlinx/dataframe/api/Merge; +} + +public final class org/jetbrains/kotlinx/dataframe/api/MergeWithTransform { + public fun (Lorg/jetbrains/kotlinx/dataframe/DataFrame;Lkotlin/jvm/functions/Function2;ZLkotlin/jvm/functions/Function2;Lkotlin/reflect/KType;Lorg/jetbrains/kotlinx/dataframe/api/Infer;)V } public final class org/jetbrains/kotlinx/dataframe/api/MinKt { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aggregation/AggregateDsl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aggregation/AggregateDsl.kt index 6bd7c2052b..ea3226ec79 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aggregation/AggregateDsl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aggregation/AggregateDsl.kt @@ -17,7 +17,7 @@ public abstract class AggregateDsl : DataFrame, ColumnSelectionDsl { - @Interpretable("GroupByInto") + @Interpretable("AggregateDslInto") public inline infix fun R.into(name: String): NamedValue = internal().yield(pathOf(name), this, typeOf()) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt index 61d03b3ff7..20f2560153 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt @@ -110,6 +110,7 @@ public fun Convert.to(type: KType): DataFrame = to { it.convertTo(t public fun Convert.to(columnConverter: DataFrame.(DataColumn) -> AnyBaseCol): DataFrame = df.replace(columns).with { columnConverter(df, it) } +@Refine @Interpretable("With0") public inline fun Convert.with( infer: Infer = Infer.Nulls, @@ -126,6 +127,8 @@ public fun Convert>.asFrame( body: ColumnsContainer.(ColumnGroup) -> DataFrame, ): DataFrame = to { body(this, it.asColumnGroup()).asColumnGroup(it.name()) } +@Refine +@Interpretable("PerRowCol") public inline fun Convert.perRowCol( infer: Infer = Infer.Nulls, noinline expression: RowColumnExpression, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/gather.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/gather.kt index 3c23bf6512..2b77cb531d 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/gather.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/gather.kt @@ -74,6 +74,7 @@ public data class Gather( public fun Gather.into(keyColumn: String, valueColumn: String): DataFrame = gatherImpl(keyColumn, valueColumn) +@AccessApiOverload public fun Gather.into( keyColumn: ColumnAccessor, valueColumn: ColumnAccessor, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/into.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/into.kt index 307ea4e022..0c76319186 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/into.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/into.kt @@ -5,6 +5,8 @@ import org.jetbrains.kotlinx.dataframe.AnyRow import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.RowExpression import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload +import org.jetbrains.kotlinx.dataframe.annotations.Interpretable +import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.impl.aggregation.internal import org.jetbrains.kotlinx.dataframe.impl.aggregation.withExpr @@ -14,6 +16,8 @@ import kotlin.reflect.typeOf // region GroupBy +@Refine +@Interpretable("GroupByInto") public fun GroupBy.into(column: String): DataFrame = toDataFrame(column) @AccessApiOverload diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/merge.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/merge.kt index 01ce40eb5f..e874292593 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/merge.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/merge.kt @@ -5,6 +5,8 @@ import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload +import org.jetbrains.kotlinx.dataframe.annotations.Interpretable +import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -16,6 +18,7 @@ import kotlin.reflect.KProperty import kotlin.reflect.KType import kotlin.reflect.typeOf +@Interpretable("Merge0") public fun DataFrame.merge(selector: ColumnsSelector): Merge> = Merge(this, selector, false, { it }, typeOf(), Infer.Type) @@ -44,19 +47,51 @@ public data class Merge( internal val infer: Infer, ) -public fun Merge.notNull(): Merge = copy(notNull = true) +public class MergeWithTransform( + internal val df: DataFrame, + internal val selector: ColumnsSelector, + internal val notNull: Boolean, + internal val transform: DataRow.(List) -> R, + internal val resultType: KType, + internal val infer: Infer, +) + +@Interpretable("MergeId") +public fun Merge.notNull(): Merge = copy(notNull = true) as Merge +@JvmName("notNullList") +@Interpretable("MergeId") +public fun Merge>.notNull(): Merge> = + copy(notNull = true) as Merge> + +@Refine +@Interpretable("MergeInto0") +public fun MergeWithTransform.into(columnName: String): DataFrame = into(pathOf(columnName)) + +@Refine +@Interpretable("MergeInto0") public fun Merge.into(columnName: String): DataFrame = into(pathOf(columnName)) @AccessApiOverload -public fun Merge.into(column: ColumnAccessor<*>): DataFrame = into(column.path()) +public inline fun Merge.into(column: ColumnAccessor<*>): DataFrame = into(column.path()) + +@AccessApiOverload +public inline fun MergeWithTransform.into(column: ColumnAccessor<*>): DataFrame = + into(column.path()) public fun Merge.intoList(): List = df.select(selector).rows().map { transform(it, it.values() as List) } -public fun Merge.into(path: ColumnPath): DataFrame { +public fun MergeWithTransform.intoList(): List = + df.select(selector).rows().map { transform(it, it.values() as List) } + +public fun MergeWithTransform.into(path: ColumnPath): DataFrame { // If target path exists, merge into temp path - val mergePath = if (df.getColumnOrNull(path) != null) pathOf(nameGenerator().addUnique("temp")) else path + val mergePath = if (df.getColumnOrNull(path) != null) { + pathOf(df.nameGenerator().addUnique("temp")) + } else { + path + } // move columns into group val grouped = df.move(selector).under { mergePath } @@ -82,16 +117,21 @@ public fun Merge.into(path: ColumnPath): DataFrame { return res } -public fun Merge.asStrings(): Merge = by(", ") +public fun Merge.into(path: ColumnPath): DataFrame = + MergeWithTransform(df, selector, notNull, transform, resultType, infer).into(path) + +@Interpretable("MergeId") +public fun Merge.asStrings(): MergeWithTransform = by(", ") +@Interpretable("MergeBy0") public fun Merge.by( separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", -): Merge = - Merge( +): MergeWithTransform = + MergeWithTransform( df = df, selector = selector, notNull = notNull, @@ -108,7 +148,11 @@ public fun Merge.by( infer = Infer.Nulls, ) +@Interpretable("MergeBy1") public inline fun Merge.by( infer: Infer = Infer.Nulls, crossinline transform: DataRow.(R) -> V, -): Merge = Merge(df, selector, notNull, { transform(this@by.transform(this, it)) }, typeOf(), infer) +): MergeWithTransform = + MergeWithTransform(df, selector, notNull, { + transform(this@by.transform(this, it)) + }, typeOf(), infer) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt index bc929cb58c..3494824caf 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt @@ -24,6 +24,8 @@ import kotlin.reflect.KProperty // region DataFrame +@Refine +@Interpretable("RenameMapping") public fun DataFrame.rename(vararg mappings: Pair): DataFrame = rename { mappings.map { it.first.toColumnAccessor() }.toColumnSet() } .into(*mappings.map { it.second }.toTypedArray()) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/reorder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/reorder.kt index c1b156466a..4634e72750 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/reorder.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/reorder.kt @@ -6,6 +6,8 @@ import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.Selector import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload +import org.jetbrains.kotlinx.dataframe.annotations.Interpretable +import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet import org.jetbrains.kotlinx.dataframe.impl.api.reorderImpl @@ -52,6 +54,8 @@ public fun > DataFrame.reorderColumnsBy( inFrameColumns = atAnyDepth, ).reorderImpl(desc, expression) +@Refine +@Interpretable("ReorderColumnsByName") public fun DataFrame.reorderColumnsByName(atAnyDepth: Boolean = true, desc: Boolean = false): DataFrame = reorderColumnsBy(atAnyDepth, desc) { name() } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/KotlinNotebookPluginUtils.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/KotlinNotebookPluginUtils.kt index 730b3234aa..de150fd644 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/KotlinNotebookPluginUtils.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/KotlinNotebookPluginUtils.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlinx.dataframe.api.GroupBy import org.jetbrains.kotlinx.dataframe.api.GroupClause import org.jetbrains.kotlinx.dataframe.api.InsertClause import org.jetbrains.kotlinx.dataframe.api.Merge +import org.jetbrains.kotlinx.dataframe.api.MergeWithTransform import org.jetbrains.kotlinx.dataframe.api.MoveClause import org.jetbrains.kotlinx.dataframe.api.Pivot import org.jetbrains.kotlinx.dataframe.api.PivotGroupBy @@ -165,6 +166,7 @@ public object KotlinNotebookPluginUtils { is SplitWithTransform<*, *, *>, is Split<*, *>, is Merge<*, *, *>, + is MergeWithTransform<*, *, *>, is Gather<*, *, *, *>, is Update<*, *>, is Convert<*, *>, @@ -213,6 +215,13 @@ public object KotlinNotebookPluginUtils { ), ) + is MergeWithTransform<*, *, *> -> dataframeLike.into( + generateRandomVariationOfColumnName( + "merged", + dataframeLike.df.columnNames(), + ), + ) + is Gather<*, *, *, *> -> dataframeLike.into( generateRandomVariationOfColumnName("key", dataframeLike.df.columnNames()), generateRandomVariationOfColumnName("value", dataframeLike.df.columnNames()), diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt index 31f695f407..8a1fda14d8 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTests.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlinx.dataframe.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.api.ExcessiveColumns import org.jetbrains.kotlinx.dataframe.api.GroupBy import org.jetbrains.kotlinx.dataframe.api.Infer +import org.jetbrains.kotlinx.dataframe.api.Merge import org.jetbrains.kotlinx.dataframe.api.ParserOptions import org.jetbrains.kotlinx.dataframe.api.add import org.jetbrains.kotlinx.dataframe.api.addAll @@ -190,6 +191,7 @@ import org.jetbrains.kotlinx.dataframe.typeClass import org.junit.Test import java.math.BigDecimal import java.time.LocalDate +import kotlin.reflect.KType import kotlin.reflect.jvm.jvmErasure import kotlin.reflect.typeOf @@ -1397,6 +1399,35 @@ class DataFrameTests : BaseTest() { res shouldBe expected } + @Test + fun `merge into temp`() { + dataFrameOf("a", "b", "temp")(1, null, 3) + .merge { cols("a", "b") }.into("b") + } + + inline fun Merge.typeOfElement() = typeOf() + + @Test + fun `merge not null`() { + val merge = dataFrameOf("a", "b")(1, null).merge { col("a") } + merge.typeOfElement() shouldBe typeOf() + merge.notNull().typeOfElement() shouldBe typeOf() + } + + inline fun List.typeOfElement(): KType = typeOf>().arguments[0].type!! + + @Test + fun `merge cols into list`() { + val merge = dataFrameOf("a", "b")(1, null).merge { col("a") } + merge.intoList().typeOfElement() shouldBe typeOf>() + merge.by { it }.intoList().typeOfElement() shouldBe typeOf>() + // here we can safely narrow down List to List after notNull because the default transformer creates a List from C + merge.notNull().intoList().typeOfElement() shouldBe typeOf>() + // if by notNull could go after by { }, + // we won't be able to do so because non-default transformer could introduce nulls itself: + merge.notNull().by { listOf(1, null) }.intoList().typeOfElement() shouldBe typeOf>() + } + @Test fun `generic column type`() { val d = typed.convert { city }.with { it?.toCharArray()?.toList() ?: emptyList() } diff --git a/docs/StardustDocs/topics/reorder.md b/docs/StardustDocs/topics/reorder.md index 192c4b4a5d..7c0103e2a7 100644 --- a/docs/StardustDocs/topics/reorder.md +++ b/docs/StardustDocs/topics/reorder.md @@ -7,7 +7,7 @@ Returns [`DataFrame`](DataFrame.md) with a new order of selected columns. ```text reorder { columns } [.cast() ] - .by { columnExpression } | .byDesc { columnExpression } | .byName(desc = false) { columnExpression } + .by { columnExpression } | .byDesc { columnExpression } | .byName(desc = false) columnExpression: DataColumn.(DataColumn) -> Value ``` @@ -74,19 +74,19 @@ df.reorder { name }.byName(desc = true) // [name.lastName, name.firstName] Reorders all columns ```text -reorderColumnsBy(dfs = true, desc = false) { columnExpression } +reorderColumnsBy(atAnyDepth = true, desc = false) { columnExpression } ``` **Parameters:** -* `dfs` — reorder columns inside [`ColumnGroups`](DataColumn.md#columngroup) and [`FrameColumn`](DataColumn.md#framecolumn) recursively +* `atAnyDepth` — reorder columns inside [`ColumnGroups`](DataColumn.md#columngroup) and [`FrameColumn`](DataColumn.md#framecolumn) recursively * `desc` — apply descending order ## reorderColumnsByName ```text -reorderColumnsByName(dfs = true, desc = false) +reorderColumnsByName(atAnyDepth = true, desc = false) ``` **Parameters:** -* `dfs` — reorder columns inside [`ColumnGroups`](DataColumn.md#columngroup) and [`FrameColumn`](DataColumn.md#framecolumn) recursively +* `atAnyDepth` — reorder columns inside [`ColumnGroups`](DataColumn.md#columngroup) and [`FrameColumn`](DataColumn.md#framecolumn) recursively * `desc` — apply descending order diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/DataFrameAdapter.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/DataFrameAdapter.kt index 3d09d52a2f..25e1a72c4c 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/DataFrameAdapter.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/DataFrameAdapter.kt @@ -1,15 +1,13 @@ -@file:Suppress("INVISIBLE_REFERENCE") - package org.jetbrains.kotlinx.dataframe.plugin.impl import org.jetbrains.kotlinx.dataframe.AnyCol import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.api.asDataColumn import org.jetbrains.kotlinx.dataframe.api.cast import org.jetbrains.kotlinx.dataframe.api.dataFrameOf import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.FrameColumn -import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnGroupImpl import org.jetbrains.kotlinx.dataframe.plugin.impl.api.TypeApproximation fun PluginDataFrameSchema.asDataFrame(): DataFrame { @@ -28,11 +26,10 @@ private fun List.map(): DataFrame { return dataFrameOf(columns).cast() } -@Suppress("INVISIBLE_REFERENCE") fun SimpleCol.asDataColumn(): DataColumn<*> { val column = when (this) { is SimpleDataColumn -> DataColumn.createByType(this.name, listOf(this.type)) - is SimpleColumnGroup -> DataColumn.createColumnGroup(this.name, this.columns().map()) as ColumnGroupImpl<*> + is SimpleColumnGroup -> DataColumn.createColumnGroup(this.name, this.columns().map()).asDataColumn() is SimpleFrameColumn -> DataColumn.createFrameColumn(this.name, listOf(this.columns().map())) } return column diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/add.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/add.kt index 19a66ee8a0..fbc79e5e57 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/add.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/add.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleColumnGroup import org.jetbrains.kotlinx.dataframe.plugin.impl.dataFrame import org.jetbrains.kotlinx.dataframe.plugin.impl.simpleColumnOf import org.jetbrains.kotlinx.dataframe.plugin.impl.dsl +import org.jetbrains.kotlinx.dataframe.plugin.impl.ignore import org.jetbrains.kotlinx.dataframe.plugin.impl.type typealias TypeApproximation = Marker @@ -17,6 +18,7 @@ typealias TypeApproximation = Marker class Add : AbstractSchemaModificationInterpreter() { val Arguments.receiver: PluginDataFrameSchema by dataFrame() val Arguments.name: String by arg() + val Arguments.infer by ignore() val Arguments.type: TypeApproximation by type(name("expression")) override fun Arguments.interpret(): PluginDataFrameSchema { diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/convert.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/convert.kt index e8971ab9bd..ed28bef266 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/convert.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/convert.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleDataColumn import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleFrameColumn import org.jetbrains.kotlinx.dataframe.plugin.impl.dataFrame import org.jetbrains.kotlinx.dataframe.plugin.impl.enum +import org.jetbrains.kotlinx.dataframe.plugin.impl.ignore import org.jetbrains.kotlinx.dataframe.plugin.impl.simpleColumnOf import org.jetbrains.kotlinx.dataframe.plugin.impl.type @@ -54,6 +55,7 @@ internal class Convert6 : AbstractInterpreter() { class With0 : AbstractSchemaModificationInterpreter() { val Arguments.receiver: ConvertApproximation by arg() + val Arguments.infer by ignore() val Arguments.type: TypeApproximation by type(name("rowConverter")) override fun Arguments.interpret(): PluginDataFrameSchema { @@ -61,6 +63,16 @@ class With0 : AbstractSchemaModificationInterpreter() { } } +class PerRowCol : AbstractSchemaModificationInterpreter() { + val Arguments.receiver: ConvertApproximation by arg() + val Arguments.infer by ignore() + val Arguments.type: TypeApproximation by type(name("expression")) + + override fun Arguments.interpret(): PluginDataFrameSchema { + return convertImpl(receiver.schema, receiver.columns, type) + } +} + internal fun KotlinTypeFacade.convertImpl( pluginDataFrameSchema: PluginDataFrameSchema, columns: List>, diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/groupBy.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/groupBy.kt index 0cdef0c63a..b5bc6dc9e8 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/groupBy.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/groupBy.kt @@ -44,7 +44,7 @@ class GroupByDsl { val columns = mutableListOf() } -class GroupByInto : AbstractInterpreter() { +class AggregateDslInto : AbstractInterpreter() { val Arguments.dsl: GroupByDsl by arg() val Arguments.receiver: FirExpression by arg(lens = Interpreter.Id) val Arguments.name: String by arg() @@ -146,6 +146,18 @@ fun KotlinTypeFacade.createPluginDataFrameSchema(keys: List() { + val Arguments.receiver: PluginDataFrameSchema by dataFrame() + val Arguments.selector: ColumnsResolver by arg() + + override fun Arguments.interpret(): MergeApproximation { + return MergeApproximation(receiver, selector) + } +} + +class MergeInto0 : AbstractSchemaModificationInterpreter() { + val Arguments.receiver: MergeApproximation by arg() + val Arguments.columnName: String by arg() + val Arguments.typeArg2 by type() + + override fun Arguments.interpret(): PluginDataFrameSchema { + val columns = receiver.columns.resolve(receiver.df).map { it.path.toPath() } + return merge(receiver.df, columns, pathOf(columnName), simpleColumnOf(columnName, typeArg2.type)) + } +} + +class MergeId : AbstractInterpreter() { + val Arguments.receiver: MergeApproximation by arg() + + override fun Arguments.interpret(): MergeApproximation { + return receiver + } +} + +class MergeBy0 : AbstractInterpreter() { + val Arguments.receiver: MergeApproximation by arg() + val Arguments.separator by ignore() + val Arguments.prefix by ignore() + val Arguments.postfix by ignore() + val Arguments.limit by ignore() + val Arguments.truncated by ignore() + + override fun Arguments.interpret(): MergeApproximation { + return receiver + } +} + +class MergeBy1 : AbstractInterpreter() { + val Arguments.receiver: MergeApproximation by arg() + val Arguments.infer by ignore() + val Arguments.transform by ignore() + + override fun Arguments.interpret(): MergeApproximation { + return receiver + } +} + +fun merge( + schema: PluginDataFrameSchema, + columns: List, + path: ColumnPath, + result: SimpleCol +): PluginDataFrameSchema { + val df = schema.asDataFrame() + val mergedPath = if (df.getColumnOrNull(path) != null) { + val temp = ColumnNameGenerator(df.columnNames()).addUnique("temp") + pathOf(temp) + } else { + path + } + + val grouped = df.move { columns.toColumnSet() }.under { mergedPath } + + var res = grouped.replace { mergedPath }.with { result.rename(mergedPath.columnName).asDataColumn() } + if (mergedPath != path) { + res = res.remove { path }.move { mergedPath }.into { path } + } + return res.toPluginDataFrameSchema() +} diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/rename.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/rename.kt index a8b11f2b4b..7a8644fa4e 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/rename.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/rename.kt @@ -1,5 +1,6 @@ package org.jetbrains.kotlinx.dataframe.plugin.impl.api +import org.jetbrains.kotlin.fir.expressions.FirLiteralExpression import org.jetbrains.kotlinx.dataframe.api.rename import org.jetbrains.kotlinx.dataframe.api.renameToCamelCase import org.jetbrains.kotlinx.dataframe.api.toCamelCase @@ -7,6 +8,7 @@ import org.jetbrains.kotlinx.dataframe.columns.toColumnSet 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.Interpreter import org.jetbrains.kotlinx.dataframe.plugin.impl.PluginDataFrameSchema import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleCol import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleColumnGroup @@ -40,6 +42,22 @@ class RenameInto : AbstractSchemaModificationInterpreter() { } } +class RenameMapping : AbstractSchemaModificationInterpreter() { + val Arguments.receiver by dataFrame() + val Arguments.mappings: List>> by arg() + override fun Arguments.interpret(): PluginDataFrameSchema { + val mappings = mappings.map { + val it = it.value + val name = (it.first as? FirLiteralExpression)?.value as? String + val newName = (it.second as? FirLiteralExpression)?.value as? String + if (name == null || newName == null) return PluginDataFrameSchema(emptyList()) + name to newName + } + + return receiver.asDataFrame().rename(*mappings.toTypedArray()).toPluginDataFrameSchema() + } +} + internal fun PluginDataFrameSchema.map(selected: ColumnsSet, nextName: () -> String): PluginDataFrameSchema = PluginDataFrameSchema( f(columns(), nextName, selected, emptyList()), diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/reorder.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/reorder.kt new file mode 100644 index 0000000000..1ce3d277b9 --- /dev/null +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/reorder.kt @@ -0,0 +1,20 @@ +package org.jetbrains.kotlinx.dataframe.plugin.impl.api + +import org.jetbrains.kotlinx.dataframe.api.reorderColumnsByName +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.Present +import org.jetbrains.kotlinx.dataframe.plugin.impl.asDataFrame +import org.jetbrains.kotlinx.dataframe.plugin.impl.dataFrame +import org.jetbrains.kotlinx.dataframe.plugin.impl.toPluginDataFrameSchema + +class ReorderColumnsByName : AbstractSchemaModificationInterpreter() { + val Arguments.receiver by dataFrame() + val Arguments.atAnyDepth: Boolean by arg(defaultValue = Present(true)) + val Arguments.desc: Boolean by arg(defaultValue = Present(false)) + + override fun Arguments.interpret(): PluginDataFrameSchema { + return receiver.asDataFrame().reorderColumnsByName(atAnyDepth, desc).toPluginDataFrameSchema() + } +} diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/select.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/select.kt index ede178eaa5..cdec9bb9f0 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/select.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/select.kt @@ -28,7 +28,7 @@ internal class Select0 : AbstractInterpreter() { internal class Expr0 : AbstractInterpreter() { val Arguments.receiver by ignore() val Arguments.name: String by arg(defaultValue = Present("untitled")) - val Arguments.infer: Infer by enum(defaultValue = Present(Infer.Nulls)) + val Arguments.infer by ignore() val Arguments.expression: TypeApproximation by type() override fun Arguments.interpret(): ColumnsResolver { diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/valueCounts.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/valueCounts.kt index 0dd9b2a2de..6c0c0ff307 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/valueCounts.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/valueCounts.kt @@ -1,8 +1,7 @@ -@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") - package org.jetbrains.kotlinx.dataframe.plugin.impl.api import org.jetbrains.kotlinx.dataframe.api.ValueCount +import org.jetbrains.kotlinx.dataframe.impl.ColumnNameGenerator import org.jetbrains.kotlinx.dataframe.plugin.extensions.wrap import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractSchemaModificationInterpreter import org.jetbrains.kotlinx.dataframe.plugin.impl.Arguments @@ -22,7 +21,7 @@ class ValueCounts : AbstractSchemaModificationInterpreter() { override fun Arguments.interpret(): PluginDataFrameSchema { val res = columns?.resolve(receiver)?.map { it.column } ?: receiver.columns() - val generator = org.jetbrains.kotlinx.dataframe.impl.ColumnNameGenerator(res.map { it.name }) + val generator = ColumnNameGenerator(res.map { it.name }) val count = SimpleDataColumn(generator.addUnique(resultColumn), session.builtinTypes.intType.type.wrap()) return PluginDataFrameSchema(res + count) } diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/interpret.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/interpret.kt index 93de2bebb5..f67f5fc3a2 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/interpret.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/interpret.kt @@ -145,99 +145,7 @@ fun KotlinTypeFacade.interpret( val expectedReturnType = expectedArgument.klass val value: Interpreter.Success? = when (expectedArgument.lens) { is Interpreter.Value -> { - when (val expression = it.expression) { - is FirLiteralExpression -> Interpreter.Success(expression.value!!) - is FirVarargArgumentsExpression -> { - val args = expression.arguments.map { - when (it) { - is FirLiteralExpression -> it.value - is FirCallableReferenceAccess -> { - toKPropertyApproximation(it, session) - } - is FirFunctionCall -> { - it.loadInterpreter()?.let { processor -> - interpret(it, processor, emptyMap(), reporter) - } - } - else -> null - } - - } - Interpreter.Success(args) - } - - is FirFunctionCall -> { - val interpreter = expression.loadInterpreter() - if (interpreter == null) { - // if the plugin already transformed call, its original form is the last expression of .let { } - val argument = expression.arguments.getOrNull(0) - val last = (argument as? FirAnonymousFunctionExpression)?.anonymousFunction?.body?.statements?.lastOrNull() - val call = (last as? FirReturnExpression)?.result as? FirFunctionCall - call?.loadInterpreter()?.let { - interpret(call, it, emptyMap(), reporter) - } - } else { - interpreter.let { - val result = interpret(expression, interpreter, emptyMap(), reporter) - result - } - } - } - - is FirPropertyAccessExpression -> { - (expression.calleeReference as? FirResolvedNamedReference)?.let { - val symbol = it.resolvedSymbol - val firPropertySymbol = symbol as? FirPropertySymbol - val literalInitializer = runIf(firPropertySymbol?.resolvedReturnType?.canHaveLiteralInitializer == true) { - firPropertySymbol?.resolvedInitializer as? FirLiteralExpression - } - if (symbol is FirEnumEntrySymbol) { - Interpreter.Success( - DataFrameCallableId( - packageName = symbol.callableId.packageName.asString(), - className = symbol.callableId.className!!.asString(), - callableName = symbol.callableId.callableName.asString() - ) - ) - } else if (literalInitializer != null) { - Interpreter.Success(literalInitializer.value) - } else { - Interpreter.Success(columnWithPathApproximations(expression)) - } - } - } - - is FirCallableReferenceAccess -> { - Interpreter.Success(toKPropertyApproximation(expression, session)) - } - - is FirAnonymousFunctionExpression -> { - val result = (expression.anonymousFunction.body?.statements?.lastOrNull() as? FirReturnExpression)?.result - val col: Any? = when (result) { - is FirPropertyAccessExpression -> { - columnWithPathApproximations(result) - } - - is FirFunctionCall -> { - val interpreter = result.loadInterpreter() - if (interpreter == null) { - reporter.reportInterpretationError(result, "Cannot load interpreter") - } - interpreter?.let { - val value = interpret(result, interpreter, reporter = reporter)?.value - value - } - } - - is FirErrorExpression -> null - - else -> null - } - col?.let { Interpreter.Success(it) } - } - - else -> null - } + extractValue(it.expression, reporter) } is Interpreter.ReturnType -> { @@ -312,6 +220,104 @@ fun KotlinTypeFacade.interpret( } } +private fun KotlinTypeFacade.extractValue( + expression: FirExpression?, + reporter: InterpretationErrorReporter +): Interpreter.Success? = when (expression) { + is FirLiteralExpression -> Interpreter.Success(expression.value!!) + is FirVarargArgumentsExpression -> { + val args = expression.arguments.map { + when (it) { + is FirLiteralExpression -> it.value + is FirCallableReferenceAccess -> { + toKPropertyApproximation(it, session) + } + + is FirFunctionCall -> { + it.loadInterpreter()?.let { processor -> + interpret(it, processor, emptyMap(), reporter) + } + } + + else -> null + } + + } + Interpreter.Success(args) + } + + is FirFunctionCall -> { + val interpreter = expression.loadInterpreter() + if (interpreter == null) { + // if the plugin already transformed call, its original form is the last expression of .let { } + val argument = expression.arguments.getOrNull(0) + val last = (argument as? FirAnonymousFunctionExpression)?.anonymousFunction?.body?.statements?.lastOrNull() + val call = (last as? FirReturnExpression)?.result as? FirFunctionCall + call?.loadInterpreter()?.let { + interpret(call, it, emptyMap(), reporter) + } + } else { + interpreter.let { + val result = interpret(expression, interpreter, emptyMap(), reporter) + result + } + } + } + + is FirPropertyAccessExpression -> { + (expression.calleeReference as? FirResolvedNamedReference)?.let { + val symbol = it.resolvedSymbol + val firPropertySymbol = symbol as? FirPropertySymbol + val literalInitializer = firPropertySymbol?.resolvedInitializer + + if (symbol is FirEnumEntrySymbol) { + Interpreter.Success( + DataFrameCallableId( + packageName = symbol.callableId.packageName.asString(), + className = symbol.callableId.className!!.asString(), + callableName = symbol.callableId.callableName.asString() + ) + ) + } else if (literalInitializer != null) { + extractValue(literalInitializer, reporter) + } else { + Interpreter.Success(columnWithPathApproximations(expression)) + } + } + } + + is FirCallableReferenceAccess -> { + Interpreter.Success(toKPropertyApproximation(expression, session)) + } + + is FirAnonymousFunctionExpression -> { + val result = (expression.anonymousFunction.body?.statements?.lastOrNull() as? FirReturnExpression)?.result + val col: Any? = when (result) { + is FirPropertyAccessExpression -> { + columnWithPathApproximations(result) + } + + is FirFunctionCall -> { + val interpreter = result.loadInterpreter() + if (interpreter == null) { + reporter.reportInterpretationError(result, "Cannot load interpreter") + } + interpreter?.let { + val value = interpret(result, interpreter, reporter = reporter)?.value + value + } + } + + is FirErrorExpression -> null + + else -> null + } + col?.let { Interpreter.Success(it) } + } + + else -> null +} + fun interpretationFrameworkError(message: String): Nothing = throw InterpretationFrameworkError(message) class InterpretationFrameworkError(message: String) : Error(message) @@ -360,22 +366,30 @@ fun SessionContext.pluginDataFrameSchema(coneClassLikeType: ConeClassLikeType): .mapIndexed { i, symbol -> symbol to coneClassLikeType.typeArguments[i] } .toMap() - var propertySymbols = declarationSymbols.filterIsInstance() - val annotations = propertySymbols.mapNotNull { + val propertySymbols = declarationSymbols + .filterIsInstance() + .sortPropertiesByOrderAnnotation(sessionContext = this) + + val columns = propertySymbols.mapNotNull { propertySymbol -> + columnOf(propertySymbol, mapping) + } + + return PluginDataFrameSchema(columns) +} + +private fun List.sortPropertiesByOrderAnnotation(sessionContext: SessionContext): List { + var result = this + val annotations = result.mapNotNull { val orderArgument = it.getAnnotationByClassId( Names.ORDER_ANNOTATION, - session + sessionContext.session )?.argumentMapping?.mapping?.get(Names.ORDER_ARGUMENT) (orderArgument as? FirLiteralExpression)?.value as? Int } - if (propertySymbols.size == annotations.size) { - propertySymbols = propertySymbols.zip(annotations).sortedBy { it.second }.map { it.first } - } - val columns = propertySymbols.mapNotNull { propertySymbol -> - columnOf(propertySymbol, mapping) + if (result.size == annotations.size) { + result = result.zip(annotations).sortedBy { it.second }.map { it.first } } - - return PluginDataFrameSchema(columns) + return result } private fun KotlinTypeFacade.columnWithPathApproximations(result: FirPropertyAccessExpression): ColumnsResolver { @@ -419,6 +433,7 @@ private fun SessionContext.columnOf(it: FirPropertySymbol, mapping: Map() + ?.sortPropertiesByOrderAnnotation(this) ?.mapNotNull { columnOf(it, mapping) } ?: emptyList() @@ -432,6 +447,7 @@ private fun SessionContext.columnOf(it: FirPropertySymbol, mapping: Map() + ?.sortPropertiesByOrderAnnotation(this) ?.mapNotNull { columnOf(it, mapping) } ?: emptyList() SimpleColumnGroup(name, nestedColumns) diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/loadInterpreter.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/loadInterpreter.kt index 45dc022423..cc74c4a82e 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/loadInterpreter.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/loadInterpreter.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlinx.dataframe.plugin.impl.api.Explode0 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.Expr0 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.From import org.jetbrains.kotlinx.dataframe.plugin.impl.api.Group0 -import org.jetbrains.kotlinx.dataframe.plugin.impl.api.GroupByInto +import org.jetbrains.kotlinx.dataframe.plugin.impl.api.AggregateDslInto import org.jetbrains.kotlinx.dataframe.plugin.impl.api.GroupByToDataFrame import org.jetbrains.kotlinx.dataframe.plugin.impl.api.Insert0 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.Insert1 @@ -89,7 +89,13 @@ import org.jetbrains.kotlinx.dataframe.plugin.impl.api.Flatten0 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.FlattenDefault import org.jetbrains.kotlinx.dataframe.plugin.impl.api.FrameCols0 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.GroupByAdd +import org.jetbrains.kotlinx.dataframe.plugin.impl.api.GroupByInto import org.jetbrains.kotlinx.dataframe.plugin.impl.api.MapToFrame +import org.jetbrains.kotlinx.dataframe.plugin.impl.api.Merge0 +import org.jetbrains.kotlinx.dataframe.plugin.impl.api.MergeId +import org.jetbrains.kotlinx.dataframe.plugin.impl.api.MergeBy0 +import org.jetbrains.kotlinx.dataframe.plugin.impl.api.MergeBy1 +import org.jetbrains.kotlinx.dataframe.plugin.impl.api.MergeInto0 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.Move0 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.MoveAfter0 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.MoveInto0 @@ -100,7 +106,9 @@ import org.jetbrains.kotlinx.dataframe.plugin.impl.api.MoveUnder0 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.MoveUnder1 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.PairConstructor import org.jetbrains.kotlinx.dataframe.plugin.impl.api.PairToConstructor +import org.jetbrains.kotlinx.dataframe.plugin.impl.api.PerRowCol import org.jetbrains.kotlinx.dataframe.plugin.impl.api.ReadExcel +import org.jetbrains.kotlinx.dataframe.plugin.impl.api.RenameMapping import org.jetbrains.kotlinx.dataframe.plugin.impl.api.StringColumnsConstructor import org.jetbrains.kotlinx.dataframe.plugin.impl.api.ToDataFrame import org.jetbrains.kotlinx.dataframe.plugin.impl.api.ToDataFrameColumn @@ -115,6 +123,7 @@ import org.jetbrains.kotlinx.dataframe.plugin.impl.api.UpdateWith0 import org.jetbrains.kotlinx.dataframe.plugin.impl.api.ValueCounts import org.jetbrains.kotlinx.dataframe.plugin.impl.api.RenameToCamelCase import org.jetbrains.kotlinx.dataframe.plugin.impl.api.RenameToCamelCaseClause +import org.jetbrains.kotlinx.dataframe.plugin.impl.api.ReorderColumnsByName import org.jetbrains.kotlinx.dataframe.plugin.utils.Names internal fun FirFunctionCall.loadInterpreter(session: FirSession): Interpreter<*>? { @@ -201,6 +210,7 @@ internal inline fun String.load(): T { "Convert6" -> Convert6() "To0" -> To0() "With0" -> With0() + "PerRowCol" -> PerRowCol() "Explode0" -> Explode0() "Read0" -> Read0() "Insert0" -> Insert0() @@ -217,6 +227,7 @@ internal inline fun String.load(): T { "ReadJson0" -> ReadJson0() "ReadCSV0" -> ReadCSV0() "Rename" -> Rename() + "RenameMapping" -> RenameMapping() "Select0" -> Select0() "Expr0" -> Expr0() "And0" -> And0() @@ -233,11 +244,12 @@ internal inline fun String.load(): T { "Exclude1" -> Exclude1() "RenameInto" -> RenameInto() "DataFrameGroupBy" -> DataFrameGroupBy() - "GroupByInto" -> GroupByInto() + "AggregateDslInto" -> AggregateDslInto() "ReadJsonStr" -> ReadJsonStr() "DataRowReadJsonStr" -> DataRowReadJsonStr() "ReadDelimStr" -> ReadDelimStr() "GroupByToDataFrame" -> GroupByToDataFrame() + "GroupByInto" -> GroupByInto() "ToDataFrameFrom0" -> ToDataFrameFrom() "All0" -> All0() "ColsOf0" -> ColsOf0() @@ -277,6 +289,12 @@ internal inline fun String.load(): T { "MoveToRight0" -> MoveToRight0() "MoveAfter0" -> MoveAfter0() "GroupByAdd" -> GroupByAdd() + "Merge0" -> Merge0() + "MergeInto0" -> MergeInto0() + "MergeId" -> MergeId() + "MergeBy0" -> MergeBy0() + "MergeBy1" -> MergeBy1() + "ReorderColumnsByName" -> ReorderColumnsByName() else -> error("$this") } as T } diff --git a/plugins/kotlin-dataframe/testData/box/groupBy_toDataFrame.kt b/plugins/kotlin-dataframe/testData/box/groupBy_toDataFrame.kt index c97005eaf0..a187fb874a 100644 --- a/plugins/kotlin-dataframe/testData/box/groupBy_toDataFrame.kt +++ b/plugins/kotlin-dataframe/testData/box/groupBy_toDataFrame.kt @@ -11,5 +11,9 @@ fun box(): String { val df1 = df.groupBy { b }.toDataFrame() df1.group[0].a df1.group[0].b + + val df2 = df.groupBy { b }.into("gr") + df2.gr[0].a + df2.gr[0].b return "OK" } diff --git a/plugins/kotlin-dataframe/testData/box/infer.kt b/plugins/kotlin-dataframe/testData/box/infer.kt new file mode 100644 index 0000000000..de5b1de1a1 --- /dev/null +++ b/plugins/kotlin-dataframe/testData/box/infer.kt @@ -0,0 +1,15 @@ +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 df = dataFrameOf("a")(123) + .add("b", infer = Infer.Nulls) { 123 } + .convert { b }.with(infer = Infer.None) { it.toString() } + .select { a and b and expr(infer = Infer.Nulls) { 42 } } + + val b: String = df.b[0] + val untitled: Int = df.untitled[0] + return "OK" +} diff --git a/plugins/kotlin-dataframe/testData/box/merge.kt b/plugins/kotlin-dataframe/testData/box/merge.kt new file mode 100644 index 0000000000..4882ae3c0d --- /dev/null +++ b/plugins/kotlin-dataframe/testData/box/merge.kt @@ -0,0 +1,15 @@ +x + +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 merge = dataFrameOf("a", "b")(1, null).merge { a and b } + merge.into("b").compareSchemas(strict = true) + merge.by { it }.into("b").compareSchemas(strict = true) + merge.notNull().into("b").compareSchemas(strict = true) + merge.notNull().by { it }.into("b").compareSchemas(strict = true) + return "OK" +} diff --git a/plugins/kotlin-dataframe/testData/box/perRowCol.kt b/plugins/kotlin-dataframe/testData/box/perRowCol.kt new file mode 100644 index 0000000000..c6ce5aed08 --- /dev/null +++ b/plugins/kotlin-dataframe/testData/box/perRowCol.kt @@ -0,0 +1,10 @@ +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 df = dataFrameOf("a")(123).convert { a }.perRowCol { row, col -> "" } + val value: String = df.a[0] + return "OK" +} diff --git a/plugins/kotlin-dataframe/testData/box/renameMapping.kt b/plugins/kotlin-dataframe/testData/box/renameMapping.kt new file mode 100644 index 0000000000..c4afc88c90 --- /dev/null +++ b/plugins/kotlin-dataframe/testData/box/renameMapping.kt @@ -0,0 +1,10 @@ +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 df = dataFrameOf("a")(123).rename("a" to "c") + val value: Int = df.c[0] + return "OK" +} diff --git a/plugins/kotlin-dataframe/testData/box/reorder.fir.txt b/plugins/kotlin-dataframe/testData/box/reorder.fir.txt new file mode 100644 index 0000000000..ded399e228 --- /dev/null +++ b/plugins/kotlin-dataframe/testData/box/reorder.fir.txt @@ -0,0 +1,912 @@ +FILE: reorder.kt + public final fun box(): R|kotlin/String| { + lval df: R|org/jetbrains/kotlinx/dataframe/DataFrame</Invoke_09>| = R|org/jetbrains/kotlinx/dataframe/api/dataFrameOf|(vararg(String(name), String(age), String(city), String(weight))).R|kotlin/let|/Invoke_09>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/api/DataFrameBuilder|): R|org/jetbrains/kotlinx/dataframe/DataFrame</Invoke_09>| { + local abstract class Invoke_09I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/Invoke_09I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Invoke_09I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Invoke_09I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Invoke_09I>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Invoke_09I>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Invoke_09I>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Invoke_09I>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Invoke_09I>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Invoke_09I>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope0| + + } + + local abstract class Invoke_09 : R|/Invoke_09I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + public constructor(): R|/Invoke_09| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/DataFrameBuilder.invoke|(vararg(String(Alice), Int(15), String(London), Int(54), String(Bob), Int(45), String(Dubai), Int(87), String(Charlie), Int(20), String(Moscow), Null(null), String(Charlie), Int(40), String(Milan), Null(null), String(Bob), Int(30), String(Tokyo), Int(68), String(Alice), Int(20), Null(null), Int(55), String(Charlie), Int(30), String(Moscow), Int(90))) + } + ) + lval sorted1: R|org/jetbrains/kotlinx/dataframe/DataFrame</Invoke_48>| = R|/df|.R|kotlin/let|/Invoke_09>|, R|org/jetbrains/kotlinx/dataframe/DataFrame</Invoke_48>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/DataFrame</Invoke_09>|): R|org/jetbrains/kotlinx/dataframe/DataFrame</Invoke_48>| { + local abstract class Invoke_48I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/Invoke_48I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Invoke_48I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Invoke_48I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Invoke_48I>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Invoke_48I>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Invoke_48I>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Invoke_48I>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Invoke_48I>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Invoke_48I>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope0| + + } + + local abstract class Invoke_48 : R|/Invoke_48I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + public constructor(): R|/Invoke_48| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/reorderColumnsByName|/Invoke_09|>() + } + ) + lval sorted2: R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_48>| = R|/df|.R|kotlin/let|/Invoke_09>|, R|org/jetbrains/kotlinx/dataframe/api/GroupBy</Key_32, /Group_32>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/DataFrame</Invoke_09>|): R|org/jetbrains/kotlinx/dataframe/api/GroupBy</Key_32, /Group_32>| { + local abstract class Group_32I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/Group_32I| + + } + + local final class Scope1 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope1| + + } + + local abstract class Key_32I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public constructor(): R|/Key_32I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_32I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_32I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope0| + + } + + local abstract class Key_32 : R|/Key_32I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + public constructor(): R|/Key_32| + + } + + local abstract class Group_32 : R|/Group_32I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope1: R|/Scope1| + public get(): R|/Scope1| + + public constructor(): R|/Group_32| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/groupBy|/Invoke_09|>( = groupBy@fun R|org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl</Invoke_09>|.(it: R|org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl</Invoke_09>|): R|org/jetbrains/kotlinx/dataframe/columns/ColumnsResolver<*>| { + ^ (this@R|/box|, this@R|special/anonymous|).R|/Scope0.city| + } + ) + } + ).R|kotlin/let|/Key_32, /Group_32>|, R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_92>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/api/GroupBy</Key_32, /Group_32>|): R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_92>| { + local abstract class Key_92I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + + public constructor(): R|/Key_92I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_92I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_92I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_92I>|.a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_92I>|.a: R|org/jetbrains/kotlinx/dataframe/DataColumn/A_351>>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn/A_351>>| + + public constructor(): R|/Scope0| + + } + + local abstract class A_351 : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/A_351| + + } + + local final class Scope1 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope1| + + } + + local abstract class Key_92 : R|/Key_92I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope1: R|/Scope1| + public get(): R|/Scope1| + + public constructor(): R|/Key_92| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/into|/Key_32|, R|/Group_32|>(String(a)) + } + ).R|kotlin/let|/Key_92>|, R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_48>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_92>|): R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_48>| { + local abstract class Key_48I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_421>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_421>| + + public constructor(): R|/Key_48I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_48I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_48I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_48I>|.a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_421>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_421>| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_48I>|.a: R|org/jetbrains/kotlinx/dataframe/DataColumn/A_421>>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn/A_421>>| + + public constructor(): R|/Scope0| + + } + + local abstract class A_421 : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/A_421| + + } + + local final class Scope1 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_421>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_421>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_421>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_421>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_421>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_421>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_421>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_421>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope1| + + } + + local abstract class Key_48 : R|/Key_48I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope1: R|/Scope1| + public get(): R|/Scope1| + + public constructor(): R|/Key_48| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/reorderColumnsByName|/Key_92|>() + } + ) + lval sorted3: R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_87>| = R|/df|.R|kotlin/let|/Invoke_09>|, R|org/jetbrains/kotlinx/dataframe/api/GroupBy</Key_32, /Group_32>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/DataFrame</Invoke_09>|): R|org/jetbrains/kotlinx/dataframe/api/GroupBy</Key_32, /Group_32>| { + local abstract class Group_32I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/Group_32I| + + } + + local final class Scope1 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope1| + + } + + local abstract class Key_32I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public constructor(): R|/Key_32I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_32I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_32I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope0| + + } + + local abstract class Key_32 : R|/Key_32I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + public constructor(): R|/Key_32| + + } + + local abstract class Group_32 : R|/Group_32I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope1: R|/Scope1| + public get(): R|/Scope1| + + public constructor(): R|/Group_32| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/groupBy|/Invoke_09|>( = groupBy@fun R|org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl</Invoke_09>|.(it: R|org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl</Invoke_09>|): R|org/jetbrains/kotlinx/dataframe/columns/ColumnsResolver<*>| { + ^ (this@R|/box|, this@R|special/anonymous|).R|/Scope0.city| + } + ) + } + ).R|kotlin/let|/Key_32, /Group_32>|, R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_92>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/api/GroupBy</Key_32, /Group_32>|): R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_92>| { + local abstract class Key_92I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + + public constructor(): R|/Key_92I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_92I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_92I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_92I>|.a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_92I>|.a: R|org/jetbrains/kotlinx/dataframe/DataColumn/A_351>>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn/A_351>>| + + public constructor(): R|/Scope0| + + } + + local abstract class A_351 : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/A_351| + + } + + local final class Scope1 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope1| + + } + + local abstract class Key_92 : R|/Key_92I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope1: R|/Scope1| + public get(): R|/Scope1| + + public constructor(): R|/Key_92| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/into|/Key_32|, R|/Group_32|>(String(a)) + } + ).R|kotlin/let|/Key_92>|, R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_87>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_92>|): R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_87>| { + local abstract class Key_87I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_461>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_461>| + + public constructor(): R|/Key_87I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_87I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_87I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_87I>|.a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_461>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_461>| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_87I>|.a: R|org/jetbrains/kotlinx/dataframe/DataColumn/A_461>>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn/A_461>>| + + public constructor(): R|/Scope0| + + } + + local abstract class A_461 : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/A_461| + + } + + local final class Scope1 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_461>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_461>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_461>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_461>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_461>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_461>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_461>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_461>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope1| + + } + + local abstract class Key_87 : R|/Key_87I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope1: R|/Scope1| + public get(): R|/Scope1| + + public constructor(): R|/Key_87| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/reorderColumnsByName|/Key_92|>(Boolean(true), Boolean(false)) + } + ) + lval sorted4: R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_96>| = R|/df|.R|kotlin/let|/Invoke_09>|, R|org/jetbrains/kotlinx/dataframe/api/GroupBy</Key_32, /Group_32>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/DataFrame</Invoke_09>|): R|org/jetbrains/kotlinx/dataframe/api/GroupBy</Key_32, /Group_32>| { + local abstract class Group_32I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/Group_32I| + + } + + local final class Scope1 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Group_32I>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Group_32I>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope1| + + } + + local abstract class Key_32I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public constructor(): R|/Key_32I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_32I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_32I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope0| + + } + + local abstract class Key_32 : R|/Key_32I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + public constructor(): R|/Key_32| + + } + + local abstract class Group_32 : R|/Group_32I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope1: R|/Scope1| + public get(): R|/Scope1| + + public constructor(): R|/Group_32| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/groupBy|/Invoke_09|>( = groupBy@fun R|org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl</Invoke_09>|.(it: R|org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl</Invoke_09>|): R|org/jetbrains/kotlinx/dataframe/columns/ColumnsResolver<*>| { + ^ (this@R|/box|, this@R|special/anonymous|).R|/Scope0.city| + } + ) + } + ).R|kotlin/let|/Key_32, /Group_32>|, R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_92>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/api/GroupBy</Key_32, /Group_32>|): R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_92>| { + local abstract class Key_92I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + + public constructor(): R|/Key_92I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_92I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_92I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_92I>|.a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_351>| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_92I>|.a: R|org/jetbrains/kotlinx/dataframe/DataColumn/A_351>>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn/A_351>>| + + public constructor(): R|/Scope0| + + } + + local abstract class A_351 : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/A_351| + + } + + local final class Scope1 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_351>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_351>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope1| + + } + + local abstract class Key_92 : R|/Key_92I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope1: R|/Scope1| + public get(): R|/Scope1| + + public constructor(): R|/Key_92| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/into|/Key_32|, R|/Group_32|>(String(a)) + } + ).R|kotlin/let|/Key_92>|, R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_96>|>( = fun (it: R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_92>|): R|org/jetbrains/kotlinx/dataframe/DataFrame</Key_96>| { + local abstract class Key_96I : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_921>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_921>| + + public constructor(): R|/Key_96I| + + } + + local final class Scope0 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_96I>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_96I>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Key_96I>|.a: R|org/jetbrains/kotlinx/dataframe/DataFrame</A_921>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataFrame</A_921>| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Key_96I>|.a: R|org/jetbrains/kotlinx/dataframe/DataColumn/A_921>>| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn/A_921>>| + + public constructor(): R|/Scope0| + + } + + local abstract class A_921 : R|kotlin/Any| { + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val city: R|kotlin/String?| + public get(): R|kotlin/String?| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val age: R|kotlin/Int| + public get(): R|kotlin/Int| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val name: R|kotlin/String| + public get(): R|kotlin/String| + + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public constructor(): R|/A_921| + + } + + local final class Scope1 : R|kotlin/Any| { + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_921>|.city: R|kotlin/String?| + public get(): R|kotlin/String?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_921>|.city: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_921>|.age: R|kotlin/Int| + public get(): R|kotlin/Int| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_921>|.age: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_921>|.name: R|kotlin/String| + public get(): R|kotlin/String| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_921>|.name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public final val R|org/jetbrains/kotlinx/dataframe/DataRow</A_921>|.weight: R|kotlin/Int?| + public get(): R|kotlin/Int?| + + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</A_921>|.weight: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| + + public constructor(): R|/Scope1| + + } + + local abstract class Key_96 : R|/Key_96I| { + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope0: R|/Scope0| + public get(): R|/Scope0| + + @R|org/jetbrains/kotlinx/dataframe/annotations/ScopeProperty|() public abstract val scope1: R|/Scope1| + public get(): R|/Scope1| + + public constructor(): R|/Key_96| + + } + + ^ R|/it|.R|org/jetbrains/kotlinx/dataframe/api/reorderColumnsByName|/Key_92|>(Boolean(true), Boolean(true)) + } + ) + ^box String(OK) + } diff --git a/plugins/kotlin-dataframe/testData/box/reorder.kt b/plugins/kotlin-dataframe/testData/box/reorder.kt new file mode 100644 index 0000000000..bf3d8ec76c --- /dev/null +++ b/plugins/kotlin-dataframe/testData/box/reorder.kt @@ -0,0 +1,27 @@ +// FIR_DUMP + +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 df = dataFrameOf("name", "age", "city", "weight")( + "Alice", 15, "London", 54, + "Bob", 45, "Dubai", 87, + "Charlie", 20, "Moscow", null, + "Charlie", 40, "Milan", null, + "Bob", 30, "Tokyo", 68, + "Alice", 20, null, 55, + "Charlie", 30, "Moscow", 90, + ) + + val sorted1 = df.reorderColumnsByName() + + val sorted2 = df.groupBy { city }.into("a").reorderColumnsByName() + + val sorted3 = df.groupBy { city }.into("a").reorderColumnsByName(desc = true, atAnyDepth = false) + + val sorted4 = df.groupBy { city }.into("a").reorderColumnsByName(desc = true, atAnyDepth = true) + return "OK" +} diff --git a/plugins/kotlin-dataframe/testData/diagnostics/schemaInfo.fir.txt b/plugins/kotlin-dataframe/testData/diagnostics/schemaInfo.fir.txt index 45d91fb86d..bf581a1603 100644 --- a/plugins/kotlin-dataframe/testData/diagnostics/schemaInfo.fir.txt +++ b/plugins/kotlin-dataframe/testData/diagnostics/schemaInfo.fir.txt @@ -167,16 +167,16 @@ FILE: schemaInfo.kt } local abstract class Participants_181 : R|kotlin/Any| { - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val city: R|kotlin/String| public get(): R|kotlin/String| - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val firstName: R|kotlin/String| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val firstName: R|kotlin/String| public get(): R|kotlin/String| - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val lastName: R|kotlin/String| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val lastName: R|kotlin/String| public get(): R|kotlin/String| - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val age: R|kotlin/Int| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val age: R|kotlin/Int| public get(): R|kotlin/Int| public constructor(): R|/Participants_181| @@ -261,16 +261,16 @@ FILE: schemaInfo.kt } local abstract class Participants_181 : R|kotlin/Any| { - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val city: R|kotlin/String| public get(): R|kotlin/String| - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val firstName: R|kotlin/String| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val firstName: R|kotlin/String| public get(): R|kotlin/String| - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val lastName: R|kotlin/String| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val lastName: R|kotlin/String| public get(): R|kotlin/String| - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val age: R|kotlin/Int| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val age: R|kotlin/Int| public get(): R|kotlin/Int| public constructor(): R|/Participants_181| @@ -352,16 +352,16 @@ FILE: schemaInfo.kt } local abstract class GroupParticipants_461 : R|kotlin/Any| { - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val city: R|kotlin/String| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val city: R|kotlin/String| public get(): R|kotlin/String| - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val firstName: R|kotlin/String| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(0)) public abstract val firstName: R|kotlin/String| public get(): R|kotlin/String| - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val lastName: R|kotlin/String| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(1)) public abstract val lastName: R|kotlin/String| public get(): R|kotlin/String| - @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(3)) public abstract val age: R|kotlin/Int| + @R|org/jetbrains/kotlinx/dataframe/annotations/Order|(order = Int(2)) public abstract val age: R|kotlin/Int| public get(): R|kotlin/Int| public constructor(): R|/GroupParticipants_461| diff --git a/plugins/kotlin-dataframe/tests-gen/org/jetbrains/kotlin/fir/dataframe/DataFrameBlackBoxCodegenTestGenerated.java b/plugins/kotlin-dataframe/tests-gen/org/jetbrains/kotlin/fir/dataframe/DataFrameBlackBoxCodegenTestGenerated.java index 943be4285c..256a201833 100644 --- a/plugins/kotlin-dataframe/tests-gen/org/jetbrains/kotlin/fir/dataframe/DataFrameBlackBoxCodegenTestGenerated.java +++ b/plugins/kotlin-dataframe/tests-gen/org/jetbrains/kotlin/fir/dataframe/DataFrameBlackBoxCodegenTestGenerated.java @@ -244,6 +244,12 @@ public void testGroupBy_toDataFrame() { runTest("testData/box/groupBy_toDataFrame.kt"); } + @Test + @TestMetadata("infer.kt") + public void testInfer() { + runTest("testData/box/infer.kt"); + } + @Test @TestMetadata("injectAccessors.kt") public void testInjectAccessors() { @@ -304,6 +310,12 @@ public void testMapToFrame() { runTest("testData/box/mapToFrame.kt"); } + @Test + @TestMetadata("merge.kt") + public void testMerge() { + runTest("testData/box/merge.kt"); + } + @Test @TestMetadata("modifySchemaInAggregate.kt") public void testModifySchemaInAggregate() { @@ -364,6 +376,12 @@ public void testParametrizedDataFrame() { runTest("testData/box/parametrizedDataFrame.kt"); } + @Test + @TestMetadata("perRowCol.kt") + public void testPerRowCol() { + runTest("testData/box/perRowCol.kt"); + } + @Test @TestMetadata("platformType.kt") public void testPlatformType() { @@ -460,12 +478,24 @@ public void testRename() { runTest("testData/box/rename.kt"); } + @Test + @TestMetadata("renameMapping.kt") + public void testRenameMapping() { + runTest("testData/box/renameMapping.kt"); + } + @Test @TestMetadata("renameToCamelCase.kt") public void testRenameToCamelCase() { runTest("testData/box/renameToCamelCase.kt"); } + @Test + @TestMetadata("reorder.kt") + public void testReorder() { + runTest("testData/box/reorder.kt"); + } + @Test @TestMetadata("Schema.kt") public void testSchema() {