Skip to content

perf(bigquery-jdbc): eliminate dry run to resolve statement type - #14156

Open
keshavdandeva wants to merge 3 commits into
bq-expose-statement-typefrom
jdbc/remove-dry-run
Open

perf(bigquery-jdbc): eliminate dry run to resolve statement type#14156
keshavdandeva wants to merge 3 commits into
bq-expose-statement-typefrom
jdbc/remove-dry-run

Conversation

@keshavdandeva

Copy link
Copy Markdown
Contributor

b/549675845

This PR eliminates the pre-execution dry-run query previously required to determine StatementType during query execution in the BigQuery JDBC driver.

Changes

  1. Direct StatementType Resolution: Updated BigQueryStatement.runQuery() to extract StatementType directly from TableResult (for stateless/jobless queries) or JobStatistics (for job-based queries), removing the dry-run query fallback.
  2. DML Row Count Optimization: Updated BigQueryStatement.handleQueryResult() to retrieve numDmlAffectedRows directly from TableResult, avoiding extra getJob() polling RPCs for DML statements.
  3. Unit Tests: Added test cases in BigQueryStatementTest verifying that bigquery.create() and bigquery.getJob() are never invoked during stateless query and DML executions.

@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 BigQueryStatement to retrieve the statement type and DML affected row count directly from the TableResult when available. This optimization avoids unnecessary dry runs and job retrievals during stateless query execution. Additionally, the test suite has been updated to remove obsolete dry-run mocks and includes new unit tests verifying that stateless query and DML executions behave as expected without triggering dry runs or job fetches. No review comments were provided, so there is no feedback to address.

@keshavdandeva

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 BigQueryStatement to retrieve query statistics and statement types directly from TableResult when available, preventing unnecessary dry runs and getJob RPCs during stateless query execution. The review feedback suggests optimizing the DML row count extraction logic to avoid a redundant fallback to getQueryStatisticsFromJob when TableResult statistics are present but return null affected rows.

@keshavdandeva
keshavdandeva marked this pull request as ready for review August 20, 2026 22:40
@keshavdandeva
keshavdandeva requested review from a team as code owners August 20, 2026 22:40
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