Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
cce57cc
Add SQL type mapping documentation and SQLite metadata probe for testing
AndreiKingsley Jul 24, 2026
fbadf7e
Remove `SqliteMetadataProbe` test code for investigation purposes
AndreiKingsley Jul 24, 2026
c5aa746
Merge branch 'sqlite_types_fix' into jdbc_types_tests_and_docs
AndreiKingsley Jul 28, 2026
f308cd5
updated sqlite usage
AndreiKingsley Jul 28, 2026
f8cb411
Merge branch 'master' into jdbc_types_tests_and_docs
AndreiKingsley Aug 7, 2026
d0f70c5
SQLite types tests and docs update
AndreiKingsley Aug 7, 2026
b1eed7c
Add examples for resolving SQLite type issues in troubleshooting docs
AndreiKingsley Aug 18, 2026
b5658d0
Clarify test documentation for JDBC type mapping logic
AndreiKingsley Aug 18, 2026
fa70221
Expand JDBC type mapping docs with SQLite and DuckDB examples, add de…
AndreiKingsley Aug 18, 2026
f1d33cf
Revise and expand JDBC type mapping documentation for H2, SQLite, and…
AndreiKingsley Aug 19, 2026
d5f268c
Expand SQLite JDBC type mapping documentation: clarify column type ha…
AndreiKingsley Aug 19, 2026
becda76
Clarify and refine DuckDB type mapping documentation: update links fo…
AndreiKingsley Aug 19, 2026
ecca0c5
Added the :samples test module to all contextual sources in KoDEx
Jolanrensen Aug 26, 2026
e523ace
Merge remote-tracking branch 'origin/samples-module-in-kodex' into jd…
AndreiKingsley Aug 26, 2026
8a4ac64
Add SQLite samples for custom type and column converters with accompa…
AndreiKingsley Aug 27, 2026
a95880c
move IO docs under io folder
AndreiKingsley Aug 27, 2026
1372322
Add examples for SQLite custom type and column converters in document…
AndreiKingsley Aug 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion build-logic/src/main/kotlin/dfbuild.kodex.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ afterEvaluate {
)

// use `project()` dependencies for connecting contextual KoDEx sources and -caches
// Any api/implementation/compileOnly project dependency is added as contextual context.
val contextualProjects =
sequenceOf(
configurations.api,
Expand Down Expand Up @@ -94,7 +95,10 @@ afterEvaluate {
?.sourceDirectories
?.toList()
?: emptyList()
}.toSet()
}
// Adding the `:samples` module manually
.plus<List<File>>(listOf(findRootDir().resolve("samples/src/test/kotlin")))
.toSet()

extension.contextualSourcesDirectories.convention(contextualProjectsSources)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,7 @@ import java.time.LocalTime as JavaLocalTime
* Used as a result of [DbType.getPreprocessedValueType].
*
* ### Example
* ```
* val format = LocalDateTime.Format {
* year(); char('-'); monthNumber(); char('-'); day()
* char(' ')
* hour(); char(':'); minute(); char(':'); second()
* chars(" UTC")
* }
*
* val sqliteCustom = Sqlite.withCustomConverters {
* // Every column declared with "MY_DATETIME" type is parsed from custom text into Instant.
* forType("MY_DATETIME") { raw: String? ->
* raw?.let { LocalDateTime.parse(it, format).toInstant(TimeZone.UTC) }
* }
* // Identity shortcut — pin the declared type LONGVARCHAR to `String?` regardless of
* // how SQLite's type affinity would classify it.
* forType<String?>("LONGVARCHAR")
* // The "ratio" column overrides its declared type — read as Double.
* forColumn("ratio") { raw: String -> raw.toDouble() }
* }
*
* val df = DataFrame.readSqlTable(connection, "events", dbType = sqliteCustom)
* ```
* @sample [org.jetbrains.kotlinx.dataframe.samples.io.jdbc.SqliteSamples.complexSqlite]
*/
public data class SqliteCustomTypeConverter<T, R>(
val expectedType: KType,
Expand All @@ -94,28 +73,7 @@ public data class SqliteCustomTypeConverter<T, R>(
* declared type and the built-in mapping picks the wrong Kotlin type.
*
* ### Example
* ```
* val format = LocalDateTime.Format {
* year(); char('-'); monthNumber(); char('-'); day()
* char(' ')
* hour(); char(':'); minute(); char(':'); second()
* chars(" UTC")
* }
*
* val sqliteCustom = Sqlite.withCustomConverters {
* // Every column declared with "MY_DATETIME" type is parsed from custom text into Instant.
* forType("MY_DATETIME") { raw: String? ->
* raw?.let { LocalDateTime.parse(it, format).toInstant(TimeZone.UTC) }
* }
* // Identity shortcut — pin the declared type LONGVARCHAR to `String?` regardless of
* // how SQLite's type affinity would classify it.
* forType<String?>("LONGVARCHAR")
* // The "ratio" column overrides its declared type — read as Double.
* forColumn("ratio") { raw: String -> raw.toDouble() }
* }
*
* val df = DataFrame.readSqlTable(connection, "events", dbType = sqliteCustom)
* ```
* @sample [org.jetbrains.kotlinx.dataframe.samples.io.jdbc.SqliteSamples.complexSqlite]
*/
public class SqliteCustomConvertersBuilder
@PublishedApi
Expand Down Expand Up @@ -357,6 +315,11 @@ public class Sqlite(
Types.DECIMAL, Types.NUMERIC -> return jdbcToDfConverterFor<Any>(expectedKType)
}

// 5) CLOB — stored as String.
if ("CLOB" in declaredUpper) {
return jdbcToDfConverterFor<String>(expectedKType)
}

// 5) Fallback — delegate to the base [DbType] end-to-end pipeline.
return fallbackConverter(tableColumnMetadata)
}
Expand Down Expand Up @@ -598,25 +561,7 @@ public class Sqlite(
* The converting lambda receives the raw value and returns the converted result;
*
* ### Example
* ```
* val format = LocalDateTime.Format {
* year(); char('-'); monthNumber(); char('-'); day()
* char(' ')
* hour(); char(':'); minute(); char(':'); second()
* chars(" UTC")
* }
*
* val sqliteCustom = Sqlite.withCustomConverters {
* // Every column declared with "MY_DATETIME" type is parsed from custom text into Instant.
* forType("MY_DATETIME") { raw: String? ->
* raw?.let { LocalDateTime.parse(it, format).toInstant(TimeZone.UTC) }
* }
* // The "ratio" column overrides its declared type — read as Double.
* forColumn("ratio") { raw: String -> raw.toDouble() }
* }
*
* val df = DataFrame.readSqlTable(connection, "events", dbType = sqliteCustom)
* ```
* @sample [org.jetbrains.kotlinx.dataframe.samples.io.jdbc.SqliteSamples.complexSqlite]
*/
public fun withCustomConverters(block: SqliteCustomConvertersBuilder.() -> Unit): Sqlite {
val builder = SqliteCustomConvertersBuilder().also { it.block() }
Expand Down
Loading
Loading