Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public fun NullabilityOptions.applyNullability(data: List<Any?>, expectedNulls:

public inline fun <reified T> Iterable<T>.toColumn(
name: String = "",
infer: Infer = Infer.None,
infer: Infer = Infer.Nulls,
): DataColumn<T> =
(
if (infer == Infer.Type) DataColumn.createWithTypeInference(name, asList())
Expand Down
Original file line number Diff line number Diff line change
@@ -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?"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public fun NullabilityOptions.applyNullability(data: List<Any?>, expectedNulls:

public inline fun <reified T> Iterable<T>.toColumn(
name: String = "",
infer: Infer = Infer.None,
infer: Infer = Infer.Nulls,
): DataColumn<T> =
(
if (infer == Infer.Type) DataColumn.createWithTypeInference(name, asList())
Expand Down
Original file line number Diff line number Diff line change
@@ -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?"
}
}