Skip to content

Commit 7a1ad37

Browse files
committed
improving duckdb tests
1 parent 8b2003c commit 7a1ad37

File tree

3 files changed

+654
-282
lines changed

3 files changed

+654
-282
lines changed

dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/commonTestScenarios.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package org.jetbrains.kotlinx.dataframe.io
22

3+
import io.kotest.assertions.withClue
34
import io.kotest.matchers.shouldBe
45
import org.intellij.lang.annotations.Language
6+
import org.jetbrains.kotlinx.dataframe.AnyFrame
57
import org.jetbrains.kotlinx.dataframe.DataFrame
8+
import org.jetbrains.kotlinx.dataframe.api.inferType
69
import org.jetbrains.kotlinx.dataframe.api.schema
710
import org.jetbrains.kotlinx.dataframe.io.db.MsSql
811
import 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+
}

dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/duckDbTest.kt

Lines changed: 0 additions & 282 deletions
This file was deleted.

0 commit comments

Comments
 (0)