Skip to content

Commit deabc8e

Browse files
committed
improving duckdb tests
1 parent 8b2003c commit deabc8e

File tree

3 files changed

+600
-282
lines changed

3 files changed

+600
-282
lines changed

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

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

3+
import io.kotest.assertions.withClue
4+
import io.kotest.matchers.collections.shouldBeIn
35
import io.kotest.matchers.shouldBe
46
import org.intellij.lang.annotations.Language
7+
import org.jetbrains.kotlinx.dataframe.AnyFrame
58
import org.jetbrains.kotlinx.dataframe.DataFrame
9+
import org.jetbrains.kotlinx.dataframe.api.inferType
610
import org.jetbrains.kotlinx.dataframe.api.schema
711
import org.jetbrains.kotlinx.dataframe.io.db.MsSql
12+
import org.jetbrains.kotlinx.dataframe.schema.CompareResult
813
import java.sql.Connection
914
import java.sql.ResultSet
1015
import kotlin.reflect.typeOf
@@ -128,3 +133,26 @@ internal fun inferNullability(connection: Connection) {
128133

129134
connection.createStatement().execute("DROP TABLE TestTable1")
130135
}
136+
137+
/**
138+
* Helper to check whether the provided schema matches the inferred schema.
139+
*
140+
* It must hold that all types in the provided schema are equal or super to
141+
* the corresponding types in the inferred schema.
142+
*/
143+
@Suppress("INVISIBLE_REFERENCE")
144+
fun AnyFrame.assertInferredTypesMatchSchema() {
145+
withClue({
146+
"""
147+
|Inferred schema must be <: Provided schema
148+
|
149+
|Inferred Schema:
150+
|${inferType().schema().toString().lines().joinToString("\n|")}
151+
|
152+
|Provided Schema:
153+
|${schema().toString().lines().joinToString("\n|")}
154+
""".trimMargin()
155+
}) {
156+
schema().compare(inferType().schema()).isSuperOrEqual() shouldBe true
157+
}
158+
}

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)