-
Notifications
You must be signed in to change notification settings - Fork 73
Added JDBC-integration #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
d67e25e
Created a module
zaleslaw 13c0af2
Updated a module with the inital integration and test
zaleslaw b17fdda
Added a new complex example for reading with Native SQL Query
zaleslaw 56b2484
Added an implementation for a new complex example for reading with Na…
zaleslaw 24b8b2b
Added an implementation for a new complex example for reading with Na…
zaleslaw e477a74
Added idea for test
zaleslaw 8a9b496
Added mariadb4j integration
zaleslaw b58fae6
Attempt with test containers
zaleslaw b97a6b5
Added the H2 support for testing database capabilities
zaleslaw 65810a2
Set up a draft Kotlin logging
zaleslaw 1306bdc
Started with ImportDataSchema changes
zaleslaw b4acfde
Started with ImportDataSchema changes
zaleslaw 926b540
Added missed dependencies
zaleslaw bcfe733
Added simple generation for one table
zaleslaw 7b7cb85
Finished simple prototype
zaleslaw b1ffdb1
Added some minor ideas
zaleslaw d5ab3a8
Fixed bug in the KNB test
zaleslaw fe96d02
Fixed bug in the KNB test
zaleslaw 6f8dabf
Add JDBC support to dataframe gradle plugin
zaleslaw d6dcc9f
Added API methods
zaleslaw bdb91fc
Finished API methods
zaleslaw 6bc8c3c
Added import data schema annotation support
zaleslaw 81a84de
Added import data schema annotation support
zaleslaw a7147a3
Added force-classloading for drivers
zaleslaw 0ebe177
Refactored jdbc
zaleslaw 01c4e48
Updated tests
zaleslaw 9bc0ebe
Support schema generation for SqlQuery
zaleslaw b647ace
Support schema generation for SqlQuery
zaleslaw 24968e5
Added experimental methods
zaleslaw 6498cc0
Added experimental methods
zaleslaw e8c9179
Added experimental methods
zaleslaw fd99a14
Added H2 types support
zaleslaw f9f3bb2
Added SQlite types support
zaleslaw 6dc7e8d
Added initial Postgre test data
zaleslaw 3b76f4c
Fixed PostgreSQL mapping
zaleslaw f40869f
Made test green
zaleslaw b19ca39
Added type mapping for mariadb and mysql
zaleslaw 9123779
Add test for mariadb
zaleslaw 9582a66
Added initial support for Mariadb
zaleslaw 0de6f4c
Refactored sealed hierarchy and fixed SQlite tests
zaleslaw f4ba91d
Updated test and moved coverage above 60 percentage
zaleslaw ed0d960
Implemented readAllTables function for H2
zaleslaw 4361cf5
Implemented readAllTables for other databases
zaleslaw 9a3a4f7
Added documentation
zaleslaw db2af8d
Fixed in plugins
zaleslaw 980b231
Merge branch 'master' into issue-212
zaleslaw 4ed5bb4
Fixed in plugins
zaleslaw d1f3316
Refactored toml
zaleslaw 309883a
Fixed symbol processing plugin
zaleslaw 53e05b4
Added integration test
zaleslaw 89313e8
Fixed inspections
zaleslaw 3db5d28
Added documentation
zaleslaw 8419bb0
Update SQL reading documentation
zaleslaw f9499b9
Merge branch 'master' into issue-212
zaleslaw 4a4e988
Fixed Review Part 1
zaleslaw af0fc0a
Merge remote-tracking branch 'fork/issue-212' into issue-212
zaleslaw 4ac9dfd
Fixed Review Part 1
zaleslaw f427331
Rename test files to match Kotlin conventions and refactor tests
zaleslaw 97f68f6
Refactor readAllTables method name to readAllSqlTables
zaleslaw 3d0906b
Enhance exception messages and add uniqueness check
zaleslaw 4e22936
Added buildTableMetadata method to DbType and handle JSON type issues
zaleslaw f1763c5
Ignore test cases due to configuration issues.
zaleslaw 42dfe6d
Remove SQL reading features
zaleslaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
plugins { | ||
kotlin("jvm") | ||
kotlin("libs.publisher") | ||
id("org.jetbrains.kotlinx.kover") | ||
kotlin("jupyter.api") | ||
} | ||
|
||
group = "org.jetbrains.kotlinx" | ||
|
||
val jupyterApiTCRepo: String by project | ||
|
||
repositories { | ||
mavenCentral() | ||
maven(jupyterApiTCRepo) | ||
} | ||
|
||
dependencies { | ||
api(project(":core")) | ||
implementation(libs.mariadb) | ||
implementation(libs.kotlinLogging) | ||
testImplementation(libs.sqlite) | ||
testImplementation(libs.postgresql) | ||
testImplementation(libs.mysql) | ||
testImplementation(libs.h2db) | ||
testImplementation(libs.junit) | ||
testImplementation(libs.sl4j) | ||
testImplementation(libs.kotestAssertions) { | ||
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8") | ||
} | ||
} | ||
|
||
kotlinPublications { | ||
publication { | ||
publicationName.set("dataframeJDBC") | ||
artifactId.set(project.name) | ||
description.set("JDBC support for Kotlin Dataframe") | ||
packageName.set(artifactId) | ||
} | ||
} | ||
|
||
kotlin { | ||
explicitApi() | ||
} |
53 changes: 53 additions & 0 deletions
53
dataframe-jdbc/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/Jdbc.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.jetbrains.kotlinx.dataframe.io | ||
|
||
import org.jetbrains.kotlinx.dataframe.AnyFrame | ||
import org.jetbrains.kotlinx.dataframe.DataFrame | ||
import org.jetbrains.kotlinx.dataframe.codeGen.AbstractDefaultReadMethod | ||
import org.jetbrains.kotlinx.dataframe.codeGen.DefaultReadDfMethod | ||
import org.jetbrains.kotlinx.jupyter.api.Code | ||
import java.io.File | ||
import java.io.InputStream | ||
|
||
// TODO: https://github.com/Kotlin/dataframe/issues/450 | ||
public class Jdbc : SupportedCodeGenerationFormat, SupportedDataFrameFormat { | ||
public override fun readDataFrame(stream: InputStream, header: List<String>): AnyFrame = DataFrame.readJDBC(stream) | ||
|
||
public override fun readDataFrame(file: File, header: List<String>): AnyFrame = DataFrame.readJDBC(file) | ||
override fun readCodeForGeneration( | ||
stream: InputStream, | ||
name: String, | ||
generateHelperCompanionObject: Boolean | ||
): Code { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun readCodeForGeneration( | ||
file: File, | ||
name: String, | ||
generateHelperCompanionObject: Boolean | ||
): Code { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun acceptsExtension(ext: String): Boolean = ext == "jdbc" | ||
|
||
override fun acceptsSample(sample: SupportedFormatSample): Boolean = true // Extension is enough | ||
zaleslaw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
override val testOrder: Int = 40000 | ||
|
||
override fun createDefaultReadMethod(pathRepresentation: String?): DefaultReadDfMethod { | ||
return DefaultReadJdbcMethod(pathRepresentation) | ||
} | ||
} | ||
|
||
private fun DataFrame.Companion.readJDBC(stream: File): DataFrame<*> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
private fun DataFrame.Companion.readJDBC(stream: InputStream): DataFrame<*> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
internal class DefaultReadJdbcMethod(path: String?) : AbstractDefaultReadMethod(path, MethodArguments.EMPTY, readJDBC) | ||
|
||
private const val readJDBC = "readJDBC" |
44 changes: 44 additions & 0 deletions
44
dataframe-jdbc/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/db/DbType.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.jetbrains.kotlinx.dataframe.io.db | ||
|
||
import org.jetbrains.kotlinx.dataframe.io.TableColumnMetadata | ||
import org.jetbrains.kotlinx.dataframe.schema.ColumnSchema | ||
import java.sql.ResultSet | ||
import org.jetbrains.kotlinx.dataframe.io.TableMetadata | ||
|
||
/** | ||
* The `DbType` class represents a database type used for reading dataframe from the database. | ||
* | ||
* @property [dbTypeInJdbcUrl] The name of the database as specified in the JDBC URL. | ||
*/ | ||
public abstract class DbType(public val dbTypeInJdbcUrl: String) { | ||
/** | ||
* Converts the data from the given [ResultSet] into the specified [TableColumnMetadata] type. | ||
* | ||
* @param rs The [ResultSet] containing the data to be converted. | ||
* @param tableColumnMetadata The [TableColumnMetadata] representing the target type of the conversion. | ||
* @return The converted data as an instance of [Any]. | ||
*/ | ||
public abstract fun convertDataFromResultSet(rs: ResultSet, tableColumnMetadata: TableColumnMetadata): Any? | ||
|
||
/** | ||
* Returns a [ColumnSchema] produced from [tableColumnMetadata]. | ||
*/ | ||
public abstract fun toColumnSchema(tableColumnMetadata: TableColumnMetadata): ColumnSchema | ||
|
||
/** | ||
* Checks if the given table name is a system table for the specified database type. | ||
* | ||
* @param [tableMetadata] the table object representing the table from the database. | ||
* @param [dbType] the database type to check against. | ||
* @return True if the table is a system table for the specified database type, false otherwise. | ||
*/ | ||
public abstract fun isSystemTable(tableMetadata: TableMetadata): Boolean | ||
|
||
/** | ||
* Builds the table metadata based on the database type and the ResultSet from the query. | ||
* | ||
* @param [tables] the ResultSet containing the table's meta-information. | ||
* @return the TableMetadata object representing the table metadata. | ||
*/ | ||
public abstract fun buildTableMetadata(tables: ResultSet): TableMetadata | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.