Skip to content
Open
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 @@ -97,7 +97,7 @@ public interface DataColumn<out T> : BaseColumn<T> {
public fun empty(name: String = ""): AnyCol = createValueColumn(name, emptyList<Unit>(), typeOf<Unit>())
}

public fun hasNulls(): Boolean = type().isMarkedNullable
public fun hasNulls(): Boolean = values().any { it == null }

override fun distinct(): DataColumn<T>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package org.jetbrains.kotlinx.dataframe.api

import io.kotest.matchers.shouldBe
import org.jetbrains.kotlinx.dataframe.DataColumn
import org.jetbrains.kotlinx.dataframe.hasNulls
import org.junit.Test
import kotlin.reflect.full.withNullability
import kotlin.reflect.typeOf

class ContainsTests {

Expand Down Expand Up @@ -61,4 +65,12 @@ class ContainsTests {
row.containsKey(b) shouldBe false
row.containsKey(A::b) shouldBe false
}

@Test
fun `nullable vs has nulls`() {
val nullable = DataColumn.create("nullable", listOf("a" as String?, "b" as String?, "c" as String?))
nullable.hasNulls shouldBe false
val notNullable = DataColumn.create("notNullable", listOf("a" as String?, "b" as String?, "c" as String?, null as String?), typeOf<String>().withNullability(false))
notNullable.hasNulls shouldBe true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public interface DataColumn<out T> : BaseColumn<T> {
public fun empty(name: String = ""): AnyCol = createValueColumn(name, emptyList<Unit>(), typeOf<Unit>())
}

public fun hasNulls(): Boolean = type().isMarkedNullable
public fun hasNulls(): Boolean = values().any { it == null }

override fun distinct(): DataColumn<T>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package org.jetbrains.kotlinx.dataframe.api

import io.kotest.matchers.shouldBe
import org.jetbrains.kotlinx.dataframe.DataColumn
import org.jetbrains.kotlinx.dataframe.hasNulls
import org.junit.Test
import kotlin.reflect.full.withNullability
import kotlin.reflect.typeOf

class ContainsTests {

Expand Down Expand Up @@ -61,4 +65,12 @@ class ContainsTests {
row.containsKey(b) shouldBe false
row.containsKey(A::b) shouldBe false
}

@Test
fun `nullable vs has nulls`() {
val nullable = DataColumn.create("nullable", listOf("a" as String?, "b" as String?, "c" as String?))
nullable.hasNulls shouldBe false
val notNullable = DataColumn.create("notNullable", listOf("a" as String?, "b" as String?, "c" as String?, null as String?), typeOf<String>().withNullability(false))
notNullable.hasNulls shouldBe true
}
}