diff --git a/core/api/core.api b/core/api/core.api index 32d9ea7d25..df2c21454b 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -6783,11 +6783,14 @@ public final class org/jetbrains/kotlinx/dataframe/schema/CompareResult : java/l public static final field Equals Lorg/jetbrains/kotlinx/dataframe/schema/CompareResult; public static final field IsDerived Lorg/jetbrains/kotlinx/dataframe/schema/CompareResult; public static final field IsSuper Lorg/jetbrains/kotlinx/dataframe/schema/CompareResult; + public static final field Matches Lorg/jetbrains/kotlinx/dataframe/schema/CompareResult; public static final field None Lorg/jetbrains/kotlinx/dataframe/schema/CompareResult; public final fun combine (Lorg/jetbrains/kotlinx/dataframe/schema/CompareResult;)Lorg/jetbrains/kotlinx/dataframe/schema/CompareResult; public static fun getEntries ()Lkotlin/enums/EnumEntries; public final fun isEqual ()Z public final fun isSuperOrEqual ()Z + public final fun isSuperOrMatches ()Z + public final fun matches ()Z public static fun valueOf (Ljava/lang/String;)Lorg/jetbrains/kotlinx/dataframe/schema/CompareResult; public static fun values ()[Lorg/jetbrains/kotlinx/dataframe/schema/CompareResult; } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt index 09716e6e1e..b422463432 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt @@ -42,7 +42,7 @@ import org.jetbrains.kotlinx.dataframe.schema.DataFrameSchema private fun renderNullability(nullable: Boolean) = if (nullable) "?" else "" internal fun Iterable.filterRequiredForSchema(schema: DataFrameSchema) = - filter { it.isOpen && it.schema.compare(schema, ComparisonMode.STRICT_FOR_NESTED_SCHEMAS).isSuperOrEqual() } + filter { it.isOpen && it.schema.compare(schema, ComparisonMode.STRICT_FOR_NESTED_SCHEMAS).isSuperOrMatches() } internal val charsToQuote = """[ `(){}\[\].<>'"/|\\!?@:;%^&*#$-]""".toRegex() diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/ReplCodeGeneratorImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/ReplCodeGeneratorImpl.kt index a930316633..14b892b724 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/ReplCodeGeneratorImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/ReplCodeGeneratorImpl.kt @@ -63,7 +63,7 @@ internal class ReplCodeGeneratorImpl : ReplCodeGenerator { if (currentMarker.isOpen) { val columnSchema = currentMarker.schema // for mutable properties we do strong typing only at the first processing, after that we allow its type to be more general than actual dataframe type - if (wasProcessedBefore || columnSchema == targetSchema) { + if (wasProcessedBefore || columnSchema.compare(targetSchema).matches()) { // property scheme is valid for current dataframe, but we should also check that all compatible open markers are implemented by it val requiredBaseMarkers = registeredMarkers.values.filterRequiredForSchema(columnSchema) if (requiredBaseMarkers.any() && requiredBaseMarkers.all { currentMarker.implements(it) }) { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/SchemaProcessorImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/SchemaProcessorImpl.kt index 0e5add5ac9..87290a906e 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/SchemaProcessorImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/SchemaProcessorImpl.kt @@ -23,8 +23,9 @@ internal class SchemaProcessorImpl( override val generatedMarkers = mutableListOf() private fun DataFrameSchema.getAllSuperMarkers() = - registeredMarkers - .filter { it.isOpen && it.schema.compare(this, ComparisonMode.STRICT_FOR_NESTED_SCHEMAS).isSuperOrEqual() } + registeredMarkers.filter { + it.isOpen && it.schema.compare(this, ComparisonMode.STRICT_FOR_NESTED_SCHEMAS).isSuperOrMatches() + } private fun List.onlyLeafs(): List { val skip = flatMap { it.allSuperMarkers.keys }.toSet() @@ -81,8 +82,6 @@ internal class SchemaProcessorImpl( columnSchema.nullable, renderAsList = true, ) - - else -> throw NotImplementedError() } return schema.columns.asIterable().sortedBy { it.key }.flatMapIndexed { index, column -> @@ -159,7 +158,7 @@ internal class SchemaProcessorImpl( val markerName: String val required = schema.getRequiredMarkers() val existingMarker = registeredMarkers.firstOrNull { - (!isOpen || it.isOpen) && it.schema == schema && it.implementsAll(required) + (!isOpen || it.isOpen) && it.schema.compare(schema).matches() && it.implementsAll(required) } if (existingMarker != null) { return existingMarker diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/schema/DataFrameSchemaImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/schema/DataFrameSchemaImpl.kt index aa496c7ca2..3fa6eff485 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/schema/DataFrameSchemaImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/schema/DataFrameSchemaImpl.kt @@ -3,24 +3,23 @@ package org.jetbrains.kotlinx.dataframe.impl.schema import org.jetbrains.kotlinx.dataframe.impl.renderType import org.jetbrains.kotlinx.dataframe.schema.ColumnSchema import org.jetbrains.kotlinx.dataframe.schema.CompareResult -import org.jetbrains.kotlinx.dataframe.schema.CompareResult.Equals import org.jetbrains.kotlinx.dataframe.schema.CompareResult.IsDerived import org.jetbrains.kotlinx.dataframe.schema.CompareResult.IsSuper +import org.jetbrains.kotlinx.dataframe.schema.CompareResult.Matches import org.jetbrains.kotlinx.dataframe.schema.CompareResult.None import org.jetbrains.kotlinx.dataframe.schema.ComparisonMode import org.jetbrains.kotlinx.dataframe.schema.ComparisonMode.STRICT import org.jetbrains.kotlinx.dataframe.schema.ComparisonMode.STRICT_FOR_NESTED_SCHEMAS import org.jetbrains.kotlinx.dataframe.schema.DataFrameSchema import org.jetbrains.kotlinx.dataframe.schema.plus -import kotlin.collections.forEach public class DataFrameSchemaImpl(override val columns: Map) : DataFrameSchema { override fun compare(other: DataFrameSchema, comparisonMode: ComparisonMode): CompareResult { require(other is DataFrameSchemaImpl) - if (this === other) return Equals + if (this === other) return Matches - var result: CompareResult = Equals + var result: CompareResult = Matches // check for each column in this schema if there is a column with the same name in the other schema // - if so, check those schemas for equality, taking comparisonMode into account @@ -54,11 +53,47 @@ public class DataFrameSchemaImpl(override val columns: Map return result } - override fun equals(other: Any?): Boolean = other is DataFrameSchema && this.compare(other).isEqual() + /** + * Returns `true` if, and only if, + * [this schema][this] has the same columns **in the same order** as the [other schema][other]. + * The types must also match exactly. + * + * Use [compare][DataFrameSchema.compare] it the order does not matter and + * for other comparison options. + * + * @see [DataFrameSchema.compare] + * @see [CompareResult.matches] + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is DataFrameSchema) return false + if (this.compare(other) != Matches) return false + if (columns.keys.toList() != other.columns.keys.toList()) return false + + for ((name, col) in columns) { + val other = other.columns[name]!! + when (col) { + is ColumnSchema.Group -> { + other as ColumnSchema.Group // safe to cast because of compare + if (col.schema != other.schema) return false + } + + is ColumnSchema.Frame -> { + other as ColumnSchema.Frame // safe to cast because of compare + if (col.schema != other.schema) return false + } + + // already checked by compare + is ColumnSchema.Value -> Unit + } + } + + return true + } override fun toString(): String = render() - override fun hashCode(): Int = columns.hashCode() + override fun hashCode(): Int = columns.toList().hashCode() } internal fun DataFrameSchemaImpl.render(): String { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/ColumnSchema.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/ColumnSchema.kt index cb37f01499..516535253e 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/ColumnSchema.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/ColumnSchema.kt @@ -43,7 +43,7 @@ public sealed class ColumnSchema { public fun compare(other: Value, comparisonMode: ComparisonMode = LENIENT): CompareResult = when { - type == other.type -> CompareResult.Equals + type == other.type -> CompareResult.Matches comparisonMode == STRICT -> CompareResult.None type.isSubtypeOf(other.type) -> CompareResult.IsDerived type.isSupertypeOf(other.type) -> CompareResult.IsSuper @@ -80,7 +80,7 @@ public sealed class ColumnSchema { ) + CompareResult.compareNullability(thisIsNullable = nullable, otherIsNullable = other.nullable) } - /** Checks equality just on kind, type, or schema. */ + /** Checks equality by kind, type, or schema. TODO was matching, check if == works. */ override fun equals(other: Any?): Boolean { val otherType = other as? ColumnSchema ?: return false if (otherType.kind != kind) return false @@ -94,7 +94,7 @@ public sealed class ColumnSchema { public fun compare(other: ColumnSchema, comparisonMode: ComparisonMode = LENIENT): CompareResult { if (kind != other.kind) return CompareResult.None - if (this === other) return CompareResult.Equals + if (this === other) return CompareResult.Matches return when (this) { is Value -> compare(other as Value, comparisonMode) is Group -> compare(other as Group, comparisonMode) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/CompareResult.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/CompareResult.kt index f238618058..f050b4846b 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/CompareResult.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/CompareResult.kt @@ -1,28 +1,93 @@ package org.jetbrains.kotlinx.dataframe.schema +import org.jetbrains.kotlinx.dataframe.util.COMPARE_RESULT_EQUALS + public enum class CompareResult { + + // TODO can be reintroduced at 1.1 to support "equals exactly" as CompareResult + @Deprecated( + message = COMPARE_RESULT_EQUALS, + replaceWith = ReplaceWith("Matches", "org.jetbrains.kotlinx.dataframe.schema.CompareResult.Matches"), + level = DeprecationLevel.ERROR, + ) Equals, + + /** + * If the other schema has columns this has not, + * or their columns have a more specific type than in this schema, + * this is considered "super". + */ IsSuper, + + /** + * If this schema has columns the other has not, + * or their columns have a less specific type than in this schema, + * this is considered "derived". + */ IsDerived, + + /** The two schemas are incomparable. */ None, + + /** + * Both schemas contain exactly the same columns, column groups, and frame columns, + * though their order might still be different. + */ + Matches, ; - public fun isSuperOrEqual(): Boolean = this == Equals || this == IsSuper + /** + * True if + * - both schemas contain exactly the same columns, column groups, and frame columns + * - or the other schema has columns this has not + * - or their columns have a more specific type than in this schema + * + * The column order might still be different. + */ + public fun isSuperOrMatches(): Boolean = this == Matches || this == IsSuper + + @Deprecated( + message = COMPARE_RESULT_EQUALS, + replaceWith = ReplaceWith("isSuperOrMatches()"), + level = DeprecationLevel.ERROR, + ) + public fun isSuperOrEqual(): Boolean = isSuperOrMatches() + + /** + * True if both schemas contain exactly the same columns, column groups, and frame columns, + * though their order might still be different. + */ + public fun matches(): Boolean = this == Matches + + @Deprecated( + message = COMPARE_RESULT_EQUALS, + replaceWith = ReplaceWith("matches()"), + level = DeprecationLevel.ERROR, + ) + public fun isEqual(): Boolean = this.matches() - public fun isEqual(): Boolean = this == Equals + /** + * Temporary helper method to avoid breaking changes. + */ + @Deprecated( + message = COMPARE_RESULT_EQUALS, + level = DeprecationLevel.WARNING, + ) + private fun isDeprecatedEquals(): Boolean = this != IsSuper && this != IsDerived && this != None && this != Matches public fun combine(other: CompareResult): CompareResult = when (this) { - Equals -> other + Matches -> other None -> None - IsDerived -> if (other == Equals || other == IsDerived) this else None - IsSuper -> if (other == Equals || other == IsSuper) this else None + IsDerived -> if (other == Matches || other == IsDerived || other.isDeprecatedEquals()) this else None + IsSuper -> if (other == Matches || other == IsSuper || other.isDeprecatedEquals()) this else None + else -> other } public companion object { public fun compareNullability(thisIsNullable: Boolean, otherIsNullable: Boolean): CompareResult = when { - thisIsNullable == otherIsNullable -> Equals + thisIsNullable == otherIsNullable -> Matches thisIsNullable -> IsSuper else -> IsDerived } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/DataFrameSchema.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/DataFrameSchema.kt index e0bd4248fc..f3201a2c0a 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/DataFrameSchema.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/DataFrameSchema.kt @@ -6,10 +6,16 @@ public interface DataFrameSchema { public val columns: Map /** + * Compares this schema with [other] schema. + * * @param comparisonMode The [mode][ComparisonMode] to compare the schema's by. * By default, generated markers for leafs aren't used as supertypes: `@DataSchema(isOpen = false)` * Setting [comparisonMode] to [ComparisonMode.STRICT_FOR_NESTED_SCHEMAS] takes this into account * for internal codegen logic. + * + * @return a [CompareResult] that indicates whether this schema compared to [other] is + * [matching][CompareResult.Matches] (neglecting order), + * [derived][CompareResult.IsDerived], [superset][CompareResult.IsSuper], or [incomparable][CompareResult.None]. */ public fun compare(other: DataFrameSchema, comparisonMode: ComparisonMode = ComparisonMode.LENIENT): CompareResult } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt index 4c350dda87..7f32155553 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt @@ -147,6 +147,9 @@ internal const val DISPLAY_CONFIGURATION = "This constructor is only here for bi internal const val DISPLAY_CONFIGURATION_COPY = "This function is only here for binary compatibility. $MESSAGE_1_0" +internal const val COMPARE_RESULT_EQUALS = + "'Equals' is deprecated in favor of 'Matches' to clarify column order is irrelevant. $MESSAGE_1_0" + // endregion // region WARNING in 1.0, ERROR in 1.1 diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/MatchSchemeTests.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/MatchSchemeTests.kt index 96ad16e289..b9fad8926c 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/MatchSchemeTests.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/MatchSchemeTests.kt @@ -5,16 +5,20 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.api.add +import org.jetbrains.kotlinx.dataframe.api.after import org.jetbrains.kotlinx.dataframe.api.cast import org.jetbrains.kotlinx.dataframe.api.columnOf import org.jetbrains.kotlinx.dataframe.api.dataFrameOf import org.jetbrains.kotlinx.dataframe.api.generateCode +import org.jetbrains.kotlinx.dataframe.api.move import org.jetbrains.kotlinx.dataframe.api.schema +import org.jetbrains.kotlinx.dataframe.api.update +import org.jetbrains.kotlinx.dataframe.api.with import org.jetbrains.kotlinx.dataframe.impl.codeGen.ReplCodeGenerator import org.jetbrains.kotlinx.dataframe.io.readJsonStr -import org.jetbrains.kotlinx.dataframe.schema.CompareResult.Equals import org.jetbrains.kotlinx.dataframe.schema.CompareResult.IsDerived import org.jetbrains.kotlinx.dataframe.schema.CompareResult.IsSuper +import org.jetbrains.kotlinx.dataframe.schema.CompareResult.Matches import org.jetbrains.kotlinx.dataframe.schema.CompareResult.None import org.jetbrains.kotlinx.dataframe.schema.ComparisonMode.LENIENT import org.jetbrains.kotlinx.dataframe.schema.ComparisonMode.STRICT @@ -126,20 +130,20 @@ class MatchSchemeTests { "c" to columnOf(1, 2, 3, 4), ).schema() - scheme1.compare(scheme1, LENIENT) shouldBe Equals - scheme2.compare(scheme2, LENIENT) shouldBe Equals + scheme1.compare(scheme1, LENIENT) shouldBe Matches + scheme2.compare(scheme2, LENIENT) shouldBe Matches scheme1.compare(scheme2, LENIENT) shouldBe IsSuper scheme2.compare(scheme1, LENIENT) shouldBe IsDerived scheme1.compare(scheme3, LENIENT) shouldBe None - scheme1.compare(scheme1, STRICT_FOR_NESTED_SCHEMAS) shouldBe Equals - scheme2.compare(scheme2, STRICT_FOR_NESTED_SCHEMAS) shouldBe Equals + scheme1.compare(scheme1, STRICT_FOR_NESTED_SCHEMAS) shouldBe Matches + scheme2.compare(scheme2, STRICT_FOR_NESTED_SCHEMAS) shouldBe Matches scheme1.compare(scheme2, STRICT_FOR_NESTED_SCHEMAS) shouldBe IsSuper scheme2.compare(scheme1, STRICT_FOR_NESTED_SCHEMAS) shouldBe IsDerived scheme1.compare(scheme3, STRICT_FOR_NESTED_SCHEMAS) shouldBe None - scheme1.compare(scheme1, STRICT) shouldBe Equals - scheme2.compare(scheme2, STRICT) shouldBe Equals + scheme1.compare(scheme1, STRICT) shouldBe Matches + scheme2.compare(scheme2, STRICT) shouldBe Matches scheme1.compare(scheme2, STRICT) shouldBe None scheme2.compare(scheme1, STRICT) shouldBe None } @@ -169,8 +173,8 @@ class MatchSchemeTests { "c" to columnOf(1, 2, 3, 4), ).schema() - scheme1.compare(scheme1, LENIENT) shouldBe Equals - scheme2.compare(scheme2, LENIENT) shouldBe Equals + scheme1.compare(scheme1, LENIENT) shouldBe Matches + scheme2.compare(scheme2, LENIENT) shouldBe Matches scheme1.compare(scheme2, LENIENT) shouldBe IsSuper scheme2.compare(scheme1, LENIENT) shouldBe IsDerived scheme1.compare(scheme3, LENIENT) shouldBe None @@ -178,8 +182,8 @@ class MatchSchemeTests { scheme1.compare(scheme4, LENIENT) shouldBe IsSuper scheme4.compare(scheme1, LENIENT) shouldBe IsDerived - scheme1.compare(scheme1, STRICT_FOR_NESTED_SCHEMAS) shouldBe Equals - scheme2.compare(scheme2, STRICT_FOR_NESTED_SCHEMAS) shouldBe Equals + scheme1.compare(scheme1, STRICT_FOR_NESTED_SCHEMAS) shouldBe Matches + scheme2.compare(scheme2, STRICT_FOR_NESTED_SCHEMAS) shouldBe Matches scheme1.compare(scheme2, STRICT_FOR_NESTED_SCHEMAS) shouldBe None scheme2.compare(scheme1, STRICT_FOR_NESTED_SCHEMAS) shouldBe None scheme1.compare(scheme3, STRICT_FOR_NESTED_SCHEMAS) shouldBe None @@ -189,11 +193,55 @@ class MatchSchemeTests { scheme2.compare(scheme4, STRICT_FOR_NESTED_SCHEMAS) shouldBe None scheme4.compare(scheme2, STRICT_FOR_NESTED_SCHEMAS) shouldBe None - scheme1.compare(scheme1, STRICT) shouldBe Equals - scheme2.compare(scheme2, STRICT) shouldBe Equals + scheme1.compare(scheme1, STRICT) shouldBe Matches + scheme2.compare(scheme2, STRICT) shouldBe Matches scheme1.compare(scheme2, STRICT) shouldBe None scheme2.compare(scheme1, STRICT) shouldBe None scheme1.compare(scheme3, STRICT) shouldBe None scheme3.compare(scheme1, STRICT) shouldBe None } + + @Test + fun `comparison with order`() { + val scheme1 = dataFrameOf( + "a" to columnOf(1, 2, 3, 4), + "b" to columnOf(1.0, 2.0, 3.0, 4.0), + ).schema() + + val scheme1a = dataFrameOf( + "a" to columnOf(1, 2, 3, 4), + "b" to columnOf(1.0, 2.0, 3.0, 4.0), + ).schema() + + val scheme2 = dataFrameOf( + "b" to columnOf(1.0, 2.0, 3.0, 4.0), + "a" to columnOf(1, 2, 3, 4), + ).schema() + + scheme1.compare(scheme1a).matches() shouldBe true + (scheme1 == scheme1a) shouldBe true + + scheme1.compare(scheme2).matches() shouldBe true + (scheme1 == scheme2) shouldBe false + } + + @Test + fun `nested comparison with order`() { + typed.schema().compare(typed.schema()).matches() shouldBe true + (typed.schema() == typed.schema()) shouldBe true + + val movedInGroup = typed.move { pageInfo.resultsPerPage }.after { pageInfo.snippets } + + typed.schema().compare(movedInGroup.schema()).matches() shouldBe true + (typed.schema() == movedInGroup.schema()) shouldBe false + + val movedInFrameAndGroup = typed + .update { items }.with { + it.move { kind }.after { id } + .move { snippet.position }.after { snippet.info } + } + + typed.schema().compare(movedInFrameAndGroup.schema()).matches() shouldBe true + (typed.schema() == movedInFrameAndGroup.schema()) shouldBe false + } } diff --git a/dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/commonTestScenarios.kt b/dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/commonTestScenarios.kt index 0f5fd81080..947fe2137a 100644 --- a/dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/commonTestScenarios.kt +++ b/dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/commonTestScenarios.kt @@ -152,6 +152,6 @@ fun AnyFrame.assertInferredTypesMatchSchema() { |${schema().toString().lines().joinToString("\n|")} """.trimMargin() }) { - schema().compare(inferType().schema()).isSuperOrEqual() shouldBe true + schema().compare(inferType().schema()).isSuperOrMatches() shouldBe true } } diff --git a/dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/local/duckDbTest.kt b/dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/local/duckDbTest.kt index 10972696c4..3cc00e15a3 100644 --- a/dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/local/duckDbTest.kt +++ b/dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/local/duckDbTest.kt @@ -310,7 +310,7 @@ class DuckDbTest { subset = DataFrame.readSqlQuery(connection, """SELECT test_table.name, test_table.age FROM test_table""") } - schema.compare(Person.expected.schema()).isSuperOrEqual() shouldBe true + schema.compare(Person.expected.schema()).isSuperOrMatches() shouldBe true df.cast(verify = true) shouldBe Person.expected df.assertInferredTypesMatchSchema() @@ -355,7 +355,7 @@ class DuckDbTest { } } - schema.compare(Person.expected.schema()).isSuperOrEqual() shouldBe true + schema.compare(Person.expected.schema()).isSuperOrMatches() shouldBe true df.cast(verify = true) shouldBe Person.expected df.assertInferredTypesMatchSchema() @@ -396,7 +396,7 @@ class DuckDbTest { val df = dfs["test_table"]!! val schema = schemas["test_table"]!! - schema.compare(Person.expected.schema()).isSuperOrEqual() shouldBe true + schema.compare(Person.expected.schema()).isSuperOrMatches() shouldBe true df.cast(verify = true) shouldBe Person.expected df.assertInferredTypesMatchSchema() @@ -545,7 +545,7 @@ class DuckDbTest { df = DataFrame.readSqlTable(connection, "table1").reorderColumnsByName() } - schema.compare(GeneralPurposeTypes.expected.schema()).isSuperOrEqual() shouldBe true + schema.compare(GeneralPurposeTypes.expected.schema()).isSuperOrMatches() shouldBe true // on some systems OffsetDateTime's get converted to UTC sometimes, let's compare them as Instant instead fun AnyFrame.fixOffsetDateTime() = convert { colsOf() }.with { it.toInstant() }