readResultSet

Retrieves the schema from ResultSet.

NOTE: This function will not close connection and result set and not retrieve data from the result set.

Return

the schema of the ResultSet as a DataFrameSchema object.

Parameters

resultSet

the ResultSet obtained from executing a database query.

dbType

the type of database that the ResultSet belongs to, could be a custom object, provided by user.


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

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

Note that if input dataframe contains duplicate column names, they will be automatically renamed in the resulting DataFrame.

A ResultSet object maintains a cursor pointing to its current row of data. By default, a ResultSet object is not updatable and has a cursor that can only move forward. Therefore, you can iterate through it only once, from the first row to the last row.

For more details, refer to the official Java documentation on ResultSet.

NOTE: Reading from the ResultSet could potentially change its state.

Return

the DataFrame generated from the ResultSet data.

Parameters

resultSet

the ResultSet containing the data to read. Its state may be altered after the read operation.

dbType

the type of database that the ResultSet belongs to.

limit

the maximum number of rows to read from the ResultSet. null (default) means no limit - all available rows will be fetched or positive integer (e.g., 100) - fetch at most that many rows

inferNullability

indicates how the column nullability should be inferred.

See also


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.

Note that if input dataframe contains duplicate column names, they will be automatically renamed in the resulting DataFrame.

A ResultSet object maintains a cursor pointing to its current row of data. By default, a ResultSet object is not updatable and has a cursor that can only move forward. Therefore, you can iterate through it only once, from the first row to the last row.

For more details, refer to the official Java documentation on ResultSet.

NOTE: Reading from the ResultSet could potentially change its state.

Return

the DataFrame generated from the ResultSet data.

Parameters

resultSet

the ResultSet containing the data to read. Its state may be altered after the read operation.

connection

the connection to the database (it's required to extract the database type) that the ResultSet belongs to.

limit

the maximum number of rows to read from the ResultSet. null (default) means no limit - all available rows will be fetched or positive integer (e.g., 100) - fetch at most that many rows

inferNullability

indicates how the column nullability should be inferred.

dbType

the type of database, could be a custom object, provided by user, optional, default is null, in that case the dbType will be recognized from the resultSet.

See also