[
https://issues.apache.org/jira/browse/SPARK-47123?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated SPARK-47123:
-----------------------------------
Labels: pull-request-available (was: )
> JDBCRDD does not correctly handle errors in getQueryOutputSchema
> ----------------------------------------------------------------
>
> Key: SPARK-47123
> URL: https://issues.apache.org/jira/browse/SPARK-47123
> Project: Spark
> Issue Type: Bug
> Components: Spark Core
> Affects Versions: 3.5.0, 4.0.0
> Reporter: Pablo Langa Blanco
> Priority: Minor
> Labels: pull-request-available
>
> If there is an error executing statement.executeQuery(), it's possible that
> another error in one of the finally statements makes us not see the main
> error.
> {code:java}
> def getQueryOutputSchema(
> query: String, options: JDBCOptions, dialect: JdbcDialect): StructType
> = {
> val conn: Connection = dialect.createConnectionFactory(options)(-1)
> try {
> val statement = conn.prepareStatement(query)
> try {
> statement.setQueryTimeout(options.queryTimeout)
> val rs = statement.executeQuery()
> try {
> JdbcUtils.getSchema(rs, dialect, alwaysNullable = true,
> isTimestampNTZ = options.preferTimestampNTZ)
> } finally {
> rs.close()
> }
> } finally {
> statement.close()
> }
> } finally {
> conn.close()
> }
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]