Skip to content

Commit 0a74bc2

Browse files
committed
Fix bug in explode.
1 parent a0b9d49 commit 0a74bc2

File tree

2 files changed

+7
-0
lines changed
  • src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api
  • tests/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api

2 files changed

+7
-0
lines changed

src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/explode.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ internal fun AnyCol.explodeImpl(): AnyCol = dataFrameOf(this).explodeImpl(true)
3333

3434
internal fun <T> DataFrame<T>.explodeImpl(dropEmpty: Boolean = true, columns: ColumnsSelector<T, *>): DataFrame<T> {
3535
val columns = getColumnsWithPaths(columns)
36+
if (columns.isEmpty()) return this
3637

3738
val rowExpandSizes = indices.map { row ->
3839
columns.maxOf {

tests/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/explode.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,10 @@ class ExplodeTests {
2828
1, 3, 6, 7, null
2929
)
3030
}
31+
32+
@Test
33+
fun `explode nothing`() {
34+
val df = dataFrameOf("a", "b")(1, 2)
35+
df.explode() shouldBe df
36+
}
3137
}

0 commit comments

Comments
 (0)