diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/expr.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/expr.kt index bc71b795a9..a030d8fa31 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/expr.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/expr.kt @@ -7,6 +7,7 @@ import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.documentation.ColumnExpression import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate import org.jetbrains.kotlinx.dataframe.documentation.LineBreak +import kotlin.reflect.typeOf // region ColumnsSelectionDsl @@ -65,6 +66,6 @@ public inline fun ColumnsSelectionDsl.expr( name: String = "", infer: Infer = Infer.Nulls, noinline expression: AddExpression, -): DataColumn = mapToColumn(name, infer, expression) +): DataColumn = mapToColumn(name, typeOf(), infer, expression) // endregion diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/map.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/map.kt index 539271a2e9..b030ade7b9 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/map.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/map.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlinx.dataframe.impl.columnName import org.jetbrains.kotlinx.dataframe.impl.columns.createComputedColumnReference import org.jetbrains.kotlinx.dataframe.impl.columns.newColumn import org.jetbrains.kotlinx.dataframe.util.DEPRECATED_ACCESS_API +import org.jetbrains.kotlinx.dataframe.util.UNIFIED_SIMILAR_CS_API import kotlin.reflect.KProperty import kotlin.reflect.KType import kotlin.reflect.typeOf @@ -70,6 +71,16 @@ public inline fun DataColumn.mapIndexed( public inline fun DataFrame.map(transform: RowExpression): List = rows().map { transform(it, it) } +public inline fun DataFrame.mapToColumn( + name: String, + infer: Infer = Infer.Nulls, + noinline body: AddExpression, +): DataColumn = mapToColumn(name, typeOf(), infer, body) + +@Deprecated( + UNIFIED_SIMILAR_CS_API, + replaceWith = ReplaceWith("expr(name, infer, body)", "org.jetbrains.kotlinx.dataframe.api.Infer"), +) public inline fun ColumnsContainer.mapToColumn( name: String, infer: Infer = Infer.Nulls, @@ -92,7 +103,8 @@ public inline fun ColumnsContainer.mapToColumn( noinline body: AddExpression, ): DataColumn = mapToColumn(column, typeOf(), infer, body) -public fun ColumnsContainer.mapToColumn( +@PublishedApi +internal fun ColumnsContainer.mapToColumn( name: String, type: KType, infer: Infer = Infer.Nulls, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt index c24f934432..fcabf85ae9 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt @@ -189,6 +189,7 @@ internal const val GENERATE_CODE_REPLACE2 = internal const val GENERATE_INTERFACES = "This function is just here for binary compatibility. $MESSAGE_1_1" +internal const val UNIFIED_SIMILAR_CS_API = "Deprecated duplicated functionality. $MESSAGE_1_1" // endregion // region keep across releases