fix(bigquery-jdbc): ensure largeResults are handled in PreparedStatement#13496
fix(bigquery-jdbc): ensure largeResults are handled in PreparedStatement#13496logachev wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors BigQueryPreparedStatement to delegate query execution methods to its superclass BigQueryStatement, reducing code duplication. It also updates parameter handling and destination dataset configuration to work with builders, and adds corresponding unit tests. The review feedback correctly points out that the overridden execution methods in BigQueryPreparedStatement now result in redundant logging, as logQueryExecutionStart is already called within the superclass implementations. Suggestions were provided to clean up these redundant logging calls.
| public ResultSet executeQuery() throws SQLException { | ||
| logQueryExecutionStart(this.currentQuery); | ||
| try { | ||
| QueryJobConfiguration.Builder jobConfiguration = getJobConfig(this.currentQuery); | ||
| jobConfiguration.setParameterMode("POSITIONAL"); | ||
| jobConfiguration = this.parameterHandler.configureParameters(jobConfiguration); | ||
| runQuery(this.currentQuery, jobConfiguration.build()); | ||
| } catch (InterruptedException ex) { | ||
| throw new BigQueryJdbcRuntimeException("Interrupted during executeQuery", ex); | ||
| } | ||
| return getCurrentResultSet(); | ||
| return super.executeQuery(this.currentQuery); | ||
| } |
There was a problem hiding this comment.
The query execution start is logged twice because super.executeQuery(this.currentQuery) eventually delegates to executeQueryImpl(sql), which also calls logQueryExecutionStart(sql). You can safely remove the redundant call to logQueryExecutionStart here.
| public ResultSet executeQuery() throws SQLException { | |
| logQueryExecutionStart(this.currentQuery); | |
| try { | |
| QueryJobConfiguration.Builder jobConfiguration = getJobConfig(this.currentQuery); | |
| jobConfiguration.setParameterMode("POSITIONAL"); | |
| jobConfiguration = this.parameterHandler.configureParameters(jobConfiguration); | |
| runQuery(this.currentQuery, jobConfiguration.build()); | |
| } catch (InterruptedException ex) { | |
| throw new BigQueryJdbcRuntimeException("Interrupted during executeQuery", ex); | |
| } | |
| return getCurrentResultSet(); | |
| return super.executeQuery(this.currentQuery); | |
| } | |
| @Override | |
| public ResultSet executeQuery() throws SQLException { | |
| return super.executeQuery(this.currentQuery); | |
| } |
| public long executeLargeUpdate() throws SQLException { | ||
| logQueryExecutionStart(this.currentQuery); | ||
| try { | ||
| QueryJobConfiguration.Builder jobConfiguration = getJobConfig(this.currentQuery); | ||
| jobConfiguration.setParameterMode("POSITIONAL"); | ||
| jobConfiguration = this.parameterHandler.configureParameters(jobConfiguration); | ||
| runQuery(this.currentQuery, jobConfiguration.build()); | ||
| } catch (InterruptedException ex) { | ||
| throw new BigQueryJdbcRuntimeException("Interrupted during executeLargeUpdate", ex); | ||
| } | ||
| return this.currentUpdateCount; | ||
| return super.executeLargeUpdate(this.currentQuery); | ||
| } |
There was a problem hiding this comment.
The query execution start is logged twice because super.executeLargeUpdate(this.currentQuery) eventually delegates to executeLargeUpdateImpl(sql), which also calls logQueryExecutionStart(sql). You can safely remove the redundant call to logQueryExecutionStart here.
| public long executeLargeUpdate() throws SQLException { | |
| logQueryExecutionStart(this.currentQuery); | |
| try { | |
| QueryJobConfiguration.Builder jobConfiguration = getJobConfig(this.currentQuery); | |
| jobConfiguration.setParameterMode("POSITIONAL"); | |
| jobConfiguration = this.parameterHandler.configureParameters(jobConfiguration); | |
| runQuery(this.currentQuery, jobConfiguration.build()); | |
| } catch (InterruptedException ex) { | |
| throw new BigQueryJdbcRuntimeException("Interrupted during executeLargeUpdate", ex); | |
| } | |
| return this.currentUpdateCount; | |
| return super.executeLargeUpdate(this.currentQuery); | |
| } | |
| @Override | |
| public long executeLargeUpdate() throws SQLException { | |
| return super.executeLargeUpdate(this.currentQuery); | |
| } |
| public int executeUpdate() throws SQLException { | ||
| return checkUpdateCount(executeLargeUpdate()); | ||
| logQueryExecutionStart(this.currentQuery); | ||
| return super.executeUpdate(this.currentQuery); | ||
| } |
There was a problem hiding this comment.
The query execution start is logged twice because super.executeUpdate(this.currentQuery) eventually delegates to executeLargeUpdateImpl(sql), which also calls logQueryExecutionStart(sql). You can safely remove the redundant call to logQueryExecutionStart here.
| public int executeUpdate() throws SQLException { | |
| return checkUpdateCount(executeLargeUpdate()); | |
| logQueryExecutionStart(this.currentQuery); | |
| return super.executeUpdate(this.currentQuery); | |
| } | |
| @Override | |
| public int executeUpdate() throws SQLException { | |
| return super.executeUpdate(this.currentQuery); | |
| } |
| public boolean execute() throws SQLException { | ||
| logQueryExecutionStart(this.currentQuery); | ||
| try { | ||
| QueryJobConfiguration.Builder jobConfiguration = getJobConfig(this.currentQuery); | ||
| jobConfiguration.setParameterMode("POSITIONAL"); | ||
| jobConfiguration = this.parameterHandler.configureParameters(jobConfiguration); | ||
| runQuery(this.currentQuery, jobConfiguration.build()); | ||
| } catch (InterruptedException ex) { | ||
| throw new BigQueryJdbcRuntimeException("Interrupted during execute", ex); | ||
| } | ||
| return getCurrentResultSet() != null; | ||
| return super.execute(this.currentQuery); | ||
| } |
There was a problem hiding this comment.
The query execution start is logged twice because super.execute(this.currentQuery) eventually delegates to executeImpl(sql), which also calls logQueryExecutionStart(sql). You can safely remove the redundant call to logQueryExecutionStart here.
| public boolean execute() throws SQLException { | |
| logQueryExecutionStart(this.currentQuery); | |
| try { | |
| QueryJobConfiguration.Builder jobConfiguration = getJobConfig(this.currentQuery); | |
| jobConfiguration.setParameterMode("POSITIONAL"); | |
| jobConfiguration = this.parameterHandler.configureParameters(jobConfiguration); | |
| runQuery(this.currentQuery, jobConfiguration.build()); | |
| } catch (InterruptedException ex) { | |
| throw new BigQueryJdbcRuntimeException("Interrupted during execute", ex); | |
| } | |
| return getCurrentResultSet() != null; | |
| return super.execute(this.currentQuery); | |
| } | |
| @Override | |
| public boolean execute() throws SQLException { | |
| return super.execute(this.currentQuery); | |
| } |
b/524708480
Fix the issue where PreparedStatement didn't set destinationTable properties for large results.