-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(bigquery-jdbc): ensure largeResults are handled in PreparedStatement #13496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -64,8 +64,7 @@ | |||||||||||||||||||||||||||||||||||
| class BigQueryPreparedStatement extends BigQueryStatement implements PreparedStatement { | ||||||||||||||||||||||||||||||||||||
| private final BigQueryJdbcCustomLogger LOG = new BigQueryJdbcCustomLogger(this.toString()); | ||||||||||||||||||||||||||||||||||||
| private static final char POSITIONAL_PARAMETER_CHAR = '?'; | ||||||||||||||||||||||||||||||||||||
| // Making this protected so BigQueryCallableStatement subclass can access the parameters. | ||||||||||||||||||||||||||||||||||||
| protected final BigQueryParameterHandler parameterHandler; | ||||||||||||||||||||||||||||||||||||
| // parameterHandler is inherited from BigQueryStatement | ||||||||||||||||||||||||||||||||||||
| protected int parameterCount = 0; | ||||||||||||||||||||||||||||||||||||
| protected String currentQuery; | ||||||||||||||||||||||||||||||||||||
| private Queue<ArrayList<BigQueryJdbcParameter>> batchParameters = new LinkedList<>(); | ||||||||||||||||||||||||||||||||||||
|
|
@@ -91,48 +90,25 @@ private int getParameterCount(String query) { | |||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||
| 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 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); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
97
to
100
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The query execution start is logged twice because
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||
| public int executeUpdate() throws SQLException { | ||||||||||||||||||||||||||||||||||||
| return checkUpdateCount(executeLargeUpdate()); | ||||||||||||||||||||||||||||||||||||
| logQueryExecutionStart(this.currentQuery); | ||||||||||||||||||||||||||||||||||||
| return super.executeUpdate(this.currentQuery); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
103
to
106
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The query execution start is logged twice because
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||
| 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); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
109
to
112
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The query execution start is logged twice because
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query execution start is logged twice because
super.executeQuery(this.currentQuery)eventually delegates toexecuteQueryImpl(sql), which also callslogQueryExecutionStart(sql). You can safely remove the redundant call tologQueryExecutionStarthere.