Skip to content

Commit 0a3e5c3

Browse files
committed
Revert code where ColumnSchema.equals was accidental to original matches semantic
1 parent 6a321bd commit 0a3e5c3

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/SchemaProcessorImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ internal class SchemaProcessorImpl(
9191
val superFields = requiredSuperMarkers.mapNotNull { it.getField(columnName) }
9292

9393
val fieldsToOverride = superFields
94-
.filter { it.columnSchema != columnSchema }
94+
.filter { !it.columnSchema.compare(columnSchema).matches() }
9595
.map { it.fieldName }
9696
.distinctBy { it.unquoted }
9797

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/ReplCodeGenTests.kt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package org.jetbrains.kotlinx.dataframe.codeGen
22

33
import io.kotest.matchers.shouldBe
4+
import io.kotest.matchers.string.shouldContain
45
import io.kotest.matchers.string.shouldNotBeEmpty
6+
import io.kotest.matchers.string.shouldNotContain
57
import org.jetbrains.kotlinx.dataframe.AnyRow
68
import org.jetbrains.kotlinx.dataframe.ColumnsScope
79
import org.jetbrains.kotlinx.dataframe.DataColumn
810
import org.jetbrains.kotlinx.dataframe.DataRow
911
import org.jetbrains.kotlinx.dataframe.annotations.DataSchema
1012
import org.jetbrains.kotlinx.dataframe.api.add
1113
import org.jetbrains.kotlinx.dataframe.api.asFrame
14+
import org.jetbrains.kotlinx.dataframe.api.columnOf
1215
import org.jetbrains.kotlinx.dataframe.api.convert
1316
import org.jetbrains.kotlinx.dataframe.api.dataFrameOf
1417
import org.jetbrains.kotlinx.dataframe.api.filter
@@ -300,4 +303,39 @@ class ReplCodeGenTests : BaseTest() {
300303
val $dfRowName<_DataFrameType2>.leaf: $dfRowName<_DataFrameType3> @JvmName("_DataFrameType2_leaf") get() = this["leaf"] as $dfRowName<_DataFrameType3>
301304
""".trimIndent()
302305
}
306+
307+
object TestColumnOrderInGroup {
308+
@DataSchema
309+
interface Nested {
310+
val x: Int
311+
val y: String
312+
}
313+
314+
@DataSchema
315+
interface Base {
316+
val nested: Nested
317+
val extra: Int?
318+
}
319+
320+
val df = dataFrameOf(
321+
"nested" to columnOf(
322+
"y" to columnOf("hello"),
323+
"x" to columnOf(42),
324+
),
325+
"extra" to columnOf(1),
326+
)
327+
}
328+
329+
@Test
330+
fun `column order in nested group should not cause override`() {
331+
val repl = ReplCodeGenerator.create()
332+
repl.process<TestColumnOrderInGroup.Nested>()
333+
repl.process<TestColumnOrderInGroup.Base>()
334+
val c = repl.process(TestColumnOrderInGroup.df)
335+
336+
// extra: Int? → Int — valid
337+
c.declarations shouldContain "override val extra"
338+
// nested: Group{y,x} vs Group{x,y} — semantically the same, no need to override
339+
c.declarations shouldNotContain "override val nested"
340+
}
303341
}

0 commit comments

Comments
 (0)