Package-level declarations

Types

Link copied to clipboard
class DbConnectionConfig(val url: String, val user: String = "", val password: String = "", val readOnly: Boolean = true)

Represents the configuration for an internally managed JDBC database connection.

Link copied to clipboard
Link copied to clipboard

Controls how SQL queries are validated before execution.

Properties

Link copied to clipboard

Top-level SQL keywords that represent read-oriented statements. Only queries starting with one of these tokens are accepted in SqlValidation.ReadOnly mode.

Link copied to clipboard
internal const val TABLE_NAME_VALID_PATTERN: String

A regular expression defining the valid pattern for SQL table names.

Functions

Link copied to clipboard
fun buildCodeForDB(url: URL, name: String): Code
Link copied to clipboard
internal fun fetchAndConvertDataFromResultSet(dbType: DbType, tableColumns: List<TableColumnMetadata>, rs: ResultSet, limit: Int?, inferNullability: Boolean): AnyFrame

Fetches and converts data from a ResultSet into a DataFrame.

Link copied to clipboard
internal fun getExpectedJdbcTypes(dbType: DbType, tableColumns: List<TableColumnMetadata>): List<KType>
Link copied to clipboard
internal fun getPreprocessedValueTypes(dbType: DbType, tableColumns: List<TableColumnMetadata>, expectedJdbcTypes: List<KType>): List<KType>
Link copied to clipboard
Link copied to clipboard
internal fun getTargetColumnSchemas(dbType: DbType, tableColumns: List<TableColumnMetadata>, preprocessedValueTypes: List<KType>): List<ColumnSchema?>
Link copied to clipboard
internal fun isSqlQuery(sqlQueryOrTableName: String): Boolean
Link copied to clipboard
internal fun isSqlTableName(sqlQueryOrTableName: String): Boolean
Link copied to clipboard
internal fun isValidSqlQuery(sqlQuery: String): Boolean

Validates that sqlQuery is a read-only query when SqlValidation.ReadOnly is requested.

Link copied to clipboard
internal fun isValidTableName(tableName: String): Boolean

Validates that tableName is a safe SQL identifier.

Link copied to clipboard

Retrieves the schemas of all non-system tables in the database using the provided database connection.

Retrieves the schemas of all non-system tables in the database using the provided DataSource.

Retrieves the schemas of all non-system tables in the database using the provided database configuration.

fun DataFrame.Companion.readAllSqlTables(connection: Connection, catalogue: String? = null, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, configureStatement: (PreparedStatement) -> Unit = {}): Map<String, AnyFrame>
fun DataFrame.Companion.readAllSqlTables(dataSource: DataSource, catalogue: String? = null, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, configureStatement: (PreparedStatement) -> Unit = {}): Map<String, AnyFrame>

Reads all non-system tables from a database and returns them as a map of SQL tables and corresponding DataFrames.

fun DataFrame.Companion.readAllSqlTables(dbConfig: DbConnectionConfig, catalogue: String? = null, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, configureStatement: (PreparedStatement) -> Unit = {}): Map<String, AnyFrame>

Reads all non-system tables from a database and returns them as a map of SQL tables and corresponding DataFrames using the provided database configuration and limit.

Link copied to clipboard
fun ResultSet.readDataFrame(dbType: DbType, limit: Int? = null, inferNullability: Boolean = true): AnyFrame
fun ResultSet.readDataFrame(connection: Connection, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null): AnyFrame

Reads the data from a ResultSet and converts it into a DataFrame.

fun Connection.readDataFrame(sqlQueryOrTableName: String, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, validation: SqlValidation = SqlValidation.None, configureStatement: (PreparedStatement) -> Unit = {}): AnyFrame
fun DataSource.readDataFrame(sqlQueryOrTableName: String, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, validation: SqlValidation = SqlValidation.None, configureStatement: (PreparedStatement) -> Unit = {}): AnyFrame
fun DbConnectionConfig.readDataFrame(sqlQueryOrTableName: String, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, validation: SqlValidation = SqlValidation.None, configureStatement: (PreparedStatement) -> Unit = {}): AnyFrame

Converts the result of an SQL query or SQL table (by name) to the DataFrame.

Link copied to clipboard

Retrieves the schema from ResultSet.

fun Connection.readDataFrameSchema(sqlQueryOrTableName: String, dbType: DbType? = null): DataFrameSchema
fun DbConnectionConfig.readDataFrameSchema(sqlQueryOrTableName: String, dbType: DbType? = null): DataFrameSchema

Retrieves the schema of an SQL query result or the SQL table using the provided database configuration.

fun DataSource.readDataFrameSchema(sqlQueryOrTableName: String, dbType: DbType? = null): DataFrameSchema

Retrieves the schema of an SQL query result or the SQL table using the provided DataSource.

Link copied to clipboard

Retrieves the schema from ResultSet.

fun DataFrame.Companion.readResultSet(resultSet: ResultSet, dbType: DbType, limit: Int? = null, inferNullability: Boolean = true): AnyFrame
fun DataFrame.Companion.readResultSet(resultSet: ResultSet, connection: Connection, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null): AnyFrame

Reads the data from a ResultSet and converts it into a DataFrame.

Link copied to clipboard
fun DataFrameSchema.Companion.readSqlQuery(connection: Connection, sqlQuery: String, dbType: DbType? = null): DataFrameSchema

Retrieves the schema of an SQL query result using the provided database connection.

fun DataFrameSchema.Companion.readSqlQuery(dataSource: DataSource, sqlQuery: String, dbType: DbType? = null): DataFrameSchema

Retrieves the schema of an SQL query result using the provided DataSource.

Retrieves the schema of an SQL query result using the provided database configuration.

fun DataFrame.Companion.readSqlQuery(connection: Connection, sqlQuery: String, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, validation: SqlValidation = SqlValidation.None, configureStatement: (PreparedStatement) -> Unit = {}): AnyFrame
fun DataFrame.Companion.readSqlQuery(dataSource: DataSource, sqlQuery: String, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, validation: SqlValidation = SqlValidation.None, configureStatement: (PreparedStatement) -> Unit = {}): AnyFrame
fun DataFrame.Companion.readSqlQuery(dbConfig: DbConnectionConfig, sqlQuery: String, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, validation: SqlValidation = SqlValidation.None, configureStatement: (PreparedStatement) -> Unit = {}): AnyFrame

Converts the result of an SQL query to the DataFrame.

Link copied to clipboard
fun DataFrameSchema.Companion.readSqlTable(connection: Connection, tableName: String, dbType: DbType? = null): DataFrameSchema

Retrieves the schema for an SQL table using the provided database connection.

fun DataFrameSchema.Companion.readSqlTable(dataSource: DataSource, tableName: String, dbType: DbType? = null): DataFrameSchema

Retrieves the schema for an SQL table using the provided DataSource.

Retrieves the schema for an SQL table using the provided database configuration.

fun DataFrame.Companion.readSqlTable(connection: Connection, tableName: String, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, configureStatement: (PreparedStatement) -> Unit = {}): AnyFrame
fun DataFrame.Companion.readSqlTable(dataSource: DataSource, tableName: String, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, configureStatement: (PreparedStatement) -> Unit = {}): AnyFrame
fun DataFrame.Companion.readSqlTable(dbConfig: DbConnectionConfig, tableName: String, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, configureStatement: (PreparedStatement) -> Unit = {}): AnyFrame

Reads data from an SQL table and converts it into a DataFrame.

Link copied to clipboard
internal fun stripSqlNoise(sql: String): String

Strips string literals and comments from a SQL string, replacing them with a single space.

Link copied to clipboard
internal fun validateLimit(limit: Int?)

Validates the provided limit to ensure it is either null or a positive integer. Throws an IllegalArgumentException if the limit is negative or zero.

Link copied to clipboard
internal inline fun <T> withReadOnlyConnection(dbConfig: DbConnectionConfig, dbType: DbType? = null, block: (Connection) -> T): T

Executes the given block with a managed JDBC connection created from DbConnectionConfig.