Skip to content

Commit 140432f

Browse files
Automated commit of generated code
1 parent 40e1db1 commit 140432f

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/move.kt

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
1515
import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
1616
import org.jetbrains.kotlinx.dataframe.columns.UnresolvedColumnsPolicy
1717
import org.jetbrains.kotlinx.dataframe.impl.DataFrameReceiver
18+
import org.jetbrains.kotlinx.dataframe.impl.asList
1819
import org.jetbrains.kotlinx.dataframe.impl.columns.toColumnWithPath
1920
import org.jetbrains.kotlinx.dataframe.impl.columns.tree.ColumnPosition
2021
import org.jetbrains.kotlinx.dataframe.impl.columns.tree.getOrPut
@@ -35,35 +36,23 @@ internal fun <T, C> MoveClause<T, C>.afterOrBefore(column: ColumnSelector<T, *>,
3536
sourceSegments.indices.all { targetSegments[it] == sourceSegments[it] }
3637
) {
3738
throw IllegalArgumentException(
38-
"Cannot move column '${sourcePath.joinToString()}' after its child column '${targetPath.joinToString()}'",
39+
"Cannot move column '${sourcePath.joinToString()}' after its own child column '${targetPath.joinToString()}'",
3940
)
4041
}
4142
}
4243

4344
val removeRoot = removeResult.removedColumns.first().getRoot()
4445

4546
val refNode = removeRoot.getOrPut(targetPath) {
46-
val path = it.toList()
47+
val path = it.asList()
4748

48-
// Find the group reference (if any) and adjust the path
49-
val groupRefIndex = path.indexOfFirst { it.isEmpty() }
49+
// Get parent of a target path
50+
val effectivePath = path.dropLast(1)
5051

51-
// Calculate effective path and column name based on group reference
52-
val effectivePath = if (groupRefIndex >= 0) {
53-
// Nested column reference
54-
path.take(groupRefIndex)
55-
} else {
56-
path.dropLast(1)
57-
}
58-
59-
val columnName = if (groupRefIndex >= 0) {
60-
// Use the next segment after group reference, or previous if no next segment
61-
path.getOrNull(groupRefIndex + 1) ?: path[groupRefIndex - 1]
62-
} else {
63-
path.last()
64-
}
52+
// Get column name (last segment)
53+
val columnName = path.last()
6554

66-
// Get the parent group using ColumnPath
55+
// Get the parent
6756
val parent = if (effectivePath.isEmpty()) {
6857
df
6958
} else {

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/move.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,23 @@ class MoveTests {
133133
// Simple case: direct parent-child relationship
134134
shouldThrow<IllegalArgumentException> {
135135
grouped.move("a").after { "a"["b"] }
136-
}.message shouldBe "Cannot move column 'a' after its child column 'a/b'"
136+
}.message shouldBe "Cannot move column 'a' after its own child column 'a/b'"
137137

138138
// Nested case: deeper parent-child relationship
139139
shouldThrow<IllegalArgumentException> {
140140
grouped.move("a").after { "a"["c"]["d"] }
141-
}.message shouldBe "Cannot move column 'a' after its child column 'a/c/d'"
141+
}.message shouldBe "Cannot move column 'a' after its own child column 'a/c/d'"
142142

143143
// Group case: moving group after its nested column
144144
shouldThrow<IllegalArgumentException> {
145145
grouped.move { "a"["c"] }.after { "a"["c"]["d"] }
146-
}.message shouldBe "Cannot move column 'a/c' after its child column 'a/c/d'"
146+
}.message shouldBe "Cannot move column 'a/c' after its own child column 'a/c/d'"
147147
}
148148

149149
@Test
150150
fun `should throw when moving column after itself`() {
151151
shouldThrow<IllegalArgumentException> {
152152
grouped.move { "a"["b"] }.after { "a"["b"] }
153-
}.message shouldBe "Cannot move column 'a/b' after its child column 'a/b'"
153+
}.message shouldBe "Cannot move column 'a/b' after its own child column 'a/b'"
154154
}
155155
}

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/testSets/person/DataFrameTreeTests.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ class DataFrameTreeTests : BaseTest() {
527527
@Test
528528
fun moveAfter() {
529529
val moved = typed2.move { age }.after { nameAndCity.name }
530-
println(moved)
531530
moved.columnsCount() shouldBe 2
532531
moved.nameAndCity.columnsCount() shouldBe 3
533532
moved.nameAndCity.select { all() } shouldBe dataFrameOf(

0 commit comments

Comments
 (0)