Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -1672,14 +1672,18 @@ public final class org/jetbrains/kotlinx/dataframe/api/CountKt {
public static synthetic fun count$default (Lorg/jetbrains/kotlinx/dataframe/api/Grouped;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame;
}

public abstract class org/jetbrains/kotlinx/dataframe/api/CreateDataFrameDsl : org/jetbrains/kotlinx/dataframe/api/TraversePropertiesDsl {
public abstract class org/jetbrains/kotlinx/dataframe/api/CreateDataFrameDsl {
public fun <init> ()V
public abstract fun add (Lorg/jetbrains/kotlinx/dataframe/columns/BaseColumn;Lorg/jetbrains/kotlinx/dataframe/columns/ColumnPath;)V
public static synthetic fun add$default (Lorg/jetbrains/kotlinx/dataframe/api/CreateDataFrameDsl;Lorg/jetbrains/kotlinx/dataframe/columns/BaseColumn;Lorg/jetbrains/kotlinx/dataframe/columns/ColumnPath;ILjava/lang/Object;)V
public final fun exclude ([Lkotlin/reflect/KCallable;)V
public final fun exclude ([Lkotlin/reflect/KClass;)V
public abstract fun getSource ()Ljava/lang/Iterable;
public final fun into (Lorg/jetbrains/kotlinx/dataframe/columns/BaseColumn;Ljava/lang/String;)V
public final fun into (Lorg/jetbrains/kotlinx/dataframe/columns/BaseColumn;Lorg/jetbrains/kotlinx/dataframe/columns/ColumnPath;)V
public abstract fun invoke (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V
public final fun preserve ([Lkotlin/reflect/KCallable;)V
public final fun preserve ([Lkotlin/reflect/KClass;)V
public abstract fun properties ([Lkotlin/reflect/KCallable;ILkotlin/jvm/functions/Function1;)V
public static synthetic fun properties$default (Lorg/jetbrains/kotlinx/dataframe/api/CreateDataFrameDsl;[Lkotlin/reflect/KCallable;ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.jetbrains.kotlinx.dataframe.impl.columnName
import org.jetbrains.kotlinx.dataframe.impl.columns.createColumnGuessingType
import org.jetbrains.kotlinx.dataframe.index
import org.jetbrains.kotlinx.dataframe.util.DEPRECATED_ACCESS_API
import org.jetbrains.kotlinx.dataframe.util.TRAVERSE_PROPERTIES_DSL
import kotlin.reflect.KCallable
import kotlin.reflect.KClass
import kotlin.reflect.KProperty
Expand Down Expand Up @@ -188,7 +189,10 @@ public interface TraversePropertiesDsl {
@Interpretable("PreserveT")
public inline fun <reified T> TraversePropertiesDsl.preserve(): Unit = preserve(T::class)

public abstract class CreateDataFrameDsl<T> : TraversePropertiesDsl {
@Deprecated(TRAVERSE_PROPERTIES_DSL, level = DeprecationLevel.WARNING)
public inline fun <reified T> CreateDataFrameDsl<*>.preserve(): Unit = preserve(T::class)

public abstract class CreateDataFrameDsl<T> {

public abstract val source: Iterable<T>

Expand All @@ -207,6 +211,18 @@ public abstract class CreateDataFrameDsl<T> : TraversePropertiesDsl {
body: (TraversePropertiesDsl.() -> Unit)? = null,
)

@Deprecated(TRAVERSE_PROPERTIES_DSL, level = DeprecationLevel.WARNING)
public fun exclude(vararg classes: KClass<*>): Unit = properties { exclude(*classes) }

@Deprecated(TRAVERSE_PROPERTIES_DSL, level = DeprecationLevel.WARNING)
public fun exclude(vararg properties: KCallable<*>): Unit = this.properties { exclude(*properties) }

@Deprecated(TRAVERSE_PROPERTIES_DSL, level = DeprecationLevel.WARNING)
public fun preserve(vararg classes: KClass<*>): Unit = properties { preserve(*classes) }

@Deprecated(TRAVERSE_PROPERTIES_DSL, level = DeprecationLevel.WARNING)
public fun preserve(vararg properties: KCallable<*>): Unit = this.properties { preserve(*properties) }

public inline fun <reified R> expr(infer: Infer = Infer.Nulls, noinline expression: (T) -> R): DataColumn<R> =
source.map { expression(it) }.toColumn(infer = infer)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ internal class CreateDataFrameDslImpl<T>(
private val type: KType,
private val prefix: ColumnPath = emptyPath(),
private val configuration: TraverseConfiguration = TraverseConfiguration(),
) : CreateDataFrameDsl<T>(),
TraversePropertiesDsl by configuration {
) : CreateDataFrameDsl<T>() {

internal val columns = mutableListOf<Pair<ColumnPath, AnyBaseCol>>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ internal const val SUPPORTED_DATAFRAME_FORMAT: String =

private const val MESSAGE_1_1 = "Will be ERROR in 1.1."

internal const val TRAVERSE_PROPERTIES_DSL =
"Top-level `exclude`/`preserve` calls in `toDataFrame {}` are deprecated. " +
"Use a `properties { }` block to configure traversal instead. $MESSAGE_1_1"

internal const val APACHE_CSV =
"The Apache-based CSV/TSV reader is deprecated in favor of the new Deephaven CSV reader in dataframe-csv. $MESSAGE_1_1"
internal const val READ_CSV =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ class CreateDataFrameTests {
)

val res = data.toDataFrame {
preserve<NestedData>()
properties(maxDepth = 2)
properties(maxDepth = 2) {
preserve<NestedData>()
}
}

res.schema() shouldBe data.toDataFrame(maxDepth = 0).schema()
Expand Down
Loading