File tree Expand file tree Collapse file tree 3 files changed +661
-282
lines changed
dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io Expand file tree Collapse file tree 3 files changed +661
-282
lines changed Original file line number Diff line number Diff line change 11package org.jetbrains.kotlinx.dataframe.io
22
3+ import io.kotest.assertions.withClue
34import io.kotest.matchers.shouldBe
45import org.intellij.lang.annotations.Language
6+ import org.jetbrains.kotlinx.dataframe.AnyFrame
57import org.jetbrains.kotlinx.dataframe.DataFrame
8+ import org.jetbrains.kotlinx.dataframe.api.inferType
69import org.jetbrains.kotlinx.dataframe.api.schema
710import org.jetbrains.kotlinx.dataframe.io.db.MsSql
811import java.sql.Connection
@@ -128,3 +131,26 @@ internal fun inferNullability(connection: Connection) {
128131
129132 connection.createStatement().execute(" DROP TABLE TestTable1" )
130133}
134+
135+ /* *
136+ * Helper to check whether the provided schema matches the inferred schema.
137+ *
138+ * It must hold that all types in the provided schema are equal or super to
139+ * the corresponding types in the inferred schema.
140+ */
141+ @Suppress(" INVISIBLE_REFERENCE" )
142+ fun AnyFrame.assertInferredTypesMatchSchema () {
143+ withClue({
144+ """
145+ |Inferred schema must be <: Provided schema
146+ |
147+ |Inferred Schema:
148+ |${inferType().schema().toString().lines().joinToString(" \n |" )}
149+ |
150+ |Provided Schema:
151+ |${schema().toString().lines().joinToString(" \n |" )}
152+ """ .trimMargin()
153+ }) {
154+ schema().compare(inferType().schema()).isSuperOrEqual() shouldBe true
155+ }
156+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments