-
Notifications
You must be signed in to change notification settings - Fork 76
Refactored DataFrame JDBC API plus DataSource handling #1487
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
26 commits
Select commit
Hold shift + click to select a range
142c0eb
Refactored DataFrame JDBC API for enhanced DataSource handling
zaleslaw de3a97a
Refactored schema extraction to use `readSqlTable` and `readSqlQuery`…
zaleslaw 477da67
Refactored and modularized schema extraction utilities into a dedicat…
zaleslaw 448eab6
Refactor: Replace `DataFrame` with `DataFrameSchema` for schema-relat…
zaleslaw e02a6be
Update logging levels in validation utilities to debug and minor sche…
zaleslaw 7f66bf4
Refactor: support custom `PreparedStatement` configuration, unify que…
zaleslaw b53e9f1
Refactor: enhance `DbType` with batch size and query timeout properti…
zaleslaw 08d927e
Refactor: centralize `makeCommonSqlToKTypeMapping` in `DbType`, strea…
zaleslaw 9f75a84
Refactored query execution logic by introducing `readDataFrameFromDat…
zaleslaw 565e969
Refactored ResultSet-processing utilities to use mutable lists for im…
zaleslaw cc8c861
Add `configureStatement` missed parameters
zaleslaw ecbbe53
Refactored JDBC utilities: added comprehensive error handling in `rea…
zaleslaw 3310382
Update the exception type in the ` read from non-existing table` test…
zaleslaw 23f7c1b
Renamed schema extraction functions from `getSchemaFor*` to `from*` f…
zaleslaw 3377e98
Rename `fromSqlTable` and `fromSqlQuery` to `readSqlTable` and `readS…
zaleslaw e4e84c2
Update `GenerateDataSchemaTask` to use `DataFrameSchema` methods for …
zaleslaw 3aea719
Refactor: improve code consistency, update parameter documentation, s…
zaleslaw 5489889
Replace `DEFAULT_LIMIT` with nullable `limit` parameter, defaulting t…
zaleslaw 328c46f
Add `validateLimit` utility to ensure limit parameter is null or posi…
zaleslaw e007fa5
Add `validateLimit` calls across all JDBC read methods to enforce lim…
zaleslaw 56d93f5
Clarify "limit" parameter documentation and rename `readDataFrameFrom…
zaleslaw f0e4d69
Refactor JDBC data handling: relocate and centralize `buildSchemaByTa…
zaleslaw 6f2e2de
Ktlint with Junie
zaleslaw 1c772a2
Linter with Junie, part 2
zaleslaw 7009a61
Refactor and enhance JDBC: update references for improved consistency…
zaleslaw f928057
Add `DataFrameSchema.Companion` class to core API
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
1 change: 1 addition & 0 deletions
1
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/schema/DataFrameSchema.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
Large diffs are not rendered by default.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
dataframe-jdbc/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/DbConnectionConfig.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,93 @@ | ||
| package org.jetbrains.kotlinx.dataframe.io | ||
|
|
||
| /** | ||
| * Represents the configuration for an internally managed JDBC database connection. | ||
| * | ||
| * This class defines connection parameters used by the library to create a `Connection` | ||
| * when the user does not provide one explicitly. | ||
| * It is designed for safe, read-only access by default. | ||
| * | ||
| * __NOTE:__ Connections created using this configuration are managed entirely by the library. | ||
| * Users do not have access to the underlying `Connection` instance and cannot commit or close it manually. | ||
| * | ||
| * ### Read-Only Mode Behavior: | ||
| * | ||
| * When [readOnly] is `true` (default), the connection operates in read-only mode with: | ||
| * - `Connection.setReadOnly(true)` | ||
| * - `Connection.setAutoCommit(false)` | ||
| * - automatic `rollback()` at the end of execution | ||
| * | ||
| * When [readOnly] is `false`, the connection uses JDBC defaults (usually read-write), | ||
| * but the library still rejects any queries that appear to modify data | ||
| * (e.g. contain `INSERT`, `UPDATE`, `DELETE`, etc.). | ||
| * | ||
| * ### Examples: | ||
| * | ||
| * ```kotlin | ||
| * // Safe read-only connection (default) | ||
| * val config = DbConnectionConfig("jdbc:sqlite::memory:") | ||
| * val df = DataFrame.readSqlQuery(config, "SELECT * FROM books") | ||
| * | ||
| * // Use default JDBC connection settings (still protected against mutations) | ||
| * val config = DbConnectionConfig( | ||
| * url = "jdbc:sqlite::memory:", | ||
| * readOnly = false | ||
| * ) | ||
| * ``` | ||
| * | ||
| * @property [url] The JDBC URL of the database, e.g., `"jdbc:postgresql://localhost:5432/mydb"`. | ||
| * Must follow the standard format: `jdbc:subprotocol:subname`. | ||
| * | ||
| * @property [user] The username used for authentication. | ||
| * Optional, default is an empty string. | ||
| * | ||
| * @property [password] The password used for authentication. | ||
| * Optional, default is an empty string. | ||
| * | ||
| * @property [readOnly] If `true` (default), enables read-only mode. If `false`, uses JDBC defaults | ||
| * but still prevents data-modifying queries. See class documentation for details. | ||
| */ | ||
| public class DbConnectionConfig( | ||
| public val url: String, | ||
| public val user: String = "", | ||
| public val password: String = "", | ||
| public val readOnly: Boolean = true, | ||
| ) { | ||
| override fun equals(other: Any?): Boolean { | ||
| if (this === other) return true | ||
| if (other !is DbConnectionConfig) return false | ||
|
|
||
| if (url != other.url) return false | ||
| if (user != other.user) return false | ||
| if (password != other.password) return false | ||
| if (readOnly != other.readOnly) return false | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| override fun hashCode(): Int { | ||
| var result = url.hashCode() | ||
| result = 31 * result + user.hashCode() | ||
| result = 31 * result + password.hashCode() | ||
| result = 31 * result + readOnly.hashCode() | ||
| return result | ||
| } | ||
|
|
||
| override fun toString(): String = "DbConnectionConfig(url='$url', user='$user', password='***', readOnly=$readOnly)" | ||
|
|
||
| /** | ||
| * Creates a copy of this configuration with the option to override specific properties. | ||
| * | ||
| * @param url The JDBC URL. If not specified, uses the current value. | ||
| * @param user The username. If not specified, uses the current value. | ||
| * @param password The password. If not specified, uses the current value. | ||
| * @param readOnly The read-only flag. If not specified, uses the current value. | ||
| * @return A new [DbConnectionConfig] instance with the specified changes. | ||
| */ | ||
| public fun copy( | ||
zaleslaw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| url: String = this.url, | ||
| user: String = this.user, | ||
| password: String = this.password, | ||
| readOnly: Boolean = this.readOnly, | ||
| ): DbConnectionConfig = DbConnectionConfig(url, user, password, readOnly) | ||
| } | ||
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.