diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/TypeConversions.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/TypeConversions.kt index 3b0513582f..4bcaa5574d 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/TypeConversions.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/TypeConversions.kt @@ -253,7 +253,7 @@ public fun NullabilityOptions.applyNullability(data: List, expectedNulls: public inline fun Iterable.toColumn( name: String = "", - infer: Infer = Infer.None, + infer: Infer = Infer.Nulls, ): DataColumn = ( if (infer == Infer.Type) DataColumn.createWithTypeInference(name, asList()) diff --git a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/DataColumns.kt b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/DataColumns.kt new file mode 100644 index 0000000000..6061b8aba3 --- /dev/null +++ b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/DataColumns.kt @@ -0,0 +1,31 @@ +package org.jetbrains.kotlinx.dataframe.columns + +import io.kotest.matchers.shouldBe +import org.jetbrains.kotlinx.dataframe.api.toColumn +import org.jetbrains.kotlinx.dataframe.api.toDataFrame +import org.junit.Test +import java.net.URI + +class DataColumns { + @Test + fun `create column with platform type from Api`() { + val df1 = listOf(1, 2, 3).toDataFrame { + expr { URI.create("http://example.com") } into "text" + } + df1["text"].type().toString() shouldBe "java.net.URI" + } + + @Test + fun `create column with nullable platform type from Api`() { + val df1 = listOf(1, 2, 3).toDataFrame { + expr { i -> URI.create("http://example.com").takeIf { i == 2 } } into "text" + } + df1["text"].type().toString() shouldBe "java.net.URI?" + } + + @Test + fun `create column with nullable platform type from factory method`() { + val col = listOf(URI.create("http://example.com"), null).toColumn("a") + col.type().toString() shouldBe "java.net.URI?" + } +} diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/TypeConversions.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/TypeConversions.kt index 3b0513582f..4bcaa5574d 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/TypeConversions.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/TypeConversions.kt @@ -253,7 +253,7 @@ public fun NullabilityOptions.applyNullability(data: List, expectedNulls: public inline fun Iterable.toColumn( name: String = "", - infer: Infer = Infer.None, + infer: Infer = Infer.Nulls, ): DataColumn = ( if (infer == Infer.Type) DataColumn.createWithTypeInference(name, asList()) diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/DataColumns.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/DataColumns.kt new file mode 100644 index 0000000000..6061b8aba3 --- /dev/null +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/DataColumns.kt @@ -0,0 +1,31 @@ +package org.jetbrains.kotlinx.dataframe.columns + +import io.kotest.matchers.shouldBe +import org.jetbrains.kotlinx.dataframe.api.toColumn +import org.jetbrains.kotlinx.dataframe.api.toDataFrame +import org.junit.Test +import java.net.URI + +class DataColumns { + @Test + fun `create column with platform type from Api`() { + val df1 = listOf(1, 2, 3).toDataFrame { + expr { URI.create("http://example.com") } into "text" + } + df1["text"].type().toString() shouldBe "java.net.URI" + } + + @Test + fun `create column with nullable platform type from Api`() { + val df1 = listOf(1, 2, 3).toDataFrame { + expr { i -> URI.create("http://example.com").takeIf { i == 2 } } into "text" + } + df1["text"].type().toString() shouldBe "java.net.URI?" + } + + @Test + fun `create column with nullable platform type from factory method`() { + val col = listOf(URI.create("http://example.com"), null).toColumn("a") + col.type().toString() shouldBe "java.net.URI?" + } +}