Skip to content

fix(bigquery-jdbc): ensure largeResults are handled in PreparedStatement#13496

Open
logachev wants to merge 1 commit into
mainfrom
kirl/prepared_statement_large_results
Open

fix(bigquery-jdbc): ensure largeResults are handled in PreparedStatement#13496
logachev wants to merge 1 commit into
mainfrom
kirl/prepared_statement_large_results

Conversation

@logachev

@logachev logachev commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

b/524708480
Fix the issue where PreparedStatement didn't set destinationTable properties for large results.

@logachev logachev requested review from a team as code owners June 16, 2026 19:42

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 91 to 94
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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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);
}

Comment on lines 97 to 100
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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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);
}

Comment on lines 103 to 106
public int executeUpdate() throws SQLException {
return checkUpdateCount(executeLargeUpdate());
logQueryExecutionStart(this.currentQuery);
return super.executeUpdate(this.currentQuery);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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);
}

Comment on lines 109 to 112
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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant