Skip to content

feat(bigquery): expose StatementType and query execution stats on TableResult - #14145

Open
keshavdandeva wants to merge 2 commits into
mainfrom
bq-expose-statement-type
Open

feat(bigquery): expose StatementType and query execution stats on TableResult#14145
keshavdandeva wants to merge 2 commits into
mainfrom
bq-expose-statement-type

Conversation

@keshavdandeva

Copy link
Copy Markdown
Contributor

b/549680449

This PR exposes StatementType and jobless query execution metrics on TableResult by plumbing them from QueryResponse and JobStatistics.QueryStatistics.

This enables downstream consumers (such as the BigQuery JDBC driver) to inspect query statement types and execution statistics directly from TableResult without needing to issue secondary jobs or dry-run queries.

Changes

  • Dependency Update: Bumped google-api-services-bigquery to v2-rev20260731-2.0.0 in google-cloud-jar-parent/pom.xml and java-bigquery/pom.xml.
  • TableResult: Added getters, builder setters, pagination propagation (getNextPage()), toString(), hashCode(), and equals() for:
    • getStatementType() (StatementType)
    • getTotalBytesBilled() (Long)
    • getTotalBytesProcessed() (Long)
    • getTotalSlotMs() (Long)
    • getNumDmlAffectedRows() (Long)
  • BigQueryImpl: Plumbed these fields from QueryResponse when building TableResult in queryRpc().
  • Job: Plumbed StatementType and query metrics from QueryStatistics when creating TableResult in getQueryResults().
  • Tests: Added unit tests in TableResultTest and BigQueryImplTest verifying field retrieval, pagination propagation, builder modifications, and serialization.

@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 updates the BigQuery dependency version and propagates query execution statistics—including statement type, total bytes billed, total bytes processed, total slot milliseconds, and affected DML rows—from query results and job statistics into the TableResult object. The review feedback suggests wrapping the StatementType.valueOf() conversion in a try-catch block to gracefully handle any unrecognized statement types returned by the BigQuery service and prevent runtime exceptions.

@keshavdandeva
keshavdandeva marked this pull request as ready for review August 20, 2026 14:52
@keshavdandeva
keshavdandeva requested review from a team as code owners August 20, 2026 14:52
@lqiu96

lqiu96 commented Aug 20, 2026

Copy link
Copy Markdown
Member

@keshavdandeva FYI, I'm going to upgrade the bigquery apiary version in #14149

@keshavdandeva
keshavdandeva requested a review from lqiu96 August 20, 2026 22:17
@keshavdandeva
keshavdandeva force-pushed the bq-expose-statement-type branch from b333559 to 94fbc07 Compare August 20, 2026 22:33
@keshavdandeva
keshavdandeva marked this pull request as draft August 21, 2026 16:34
@keshavdandeva
keshavdandeva force-pushed the bq-expose-statement-type branch from 94fbc07 to d4f4546 Compare August 21, 2026 17:19
@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 updates the BigQuery client to expose additional query statistics and session information (such as statement type, bytes billed/processed, slot milliseconds, affected DML rows, and session info) in TableResult, along with updating the BigQuery API dependency version and adding corresponding unit tests. Feedback was provided to wrap the StatementType.valueOf conversion in a try-catch block to prevent runtime crashes if the backend returns an unrecognized statement type.

@keshavdandeva
keshavdandeva marked this pull request as ready for review August 21, 2026 17:24

public abstract TableResult.Builder setNumDmlAffectedRows(Long numDmlAffectedRows);

public abstract TableResult.Builder setSessionInfo(SessionInfo sessionInfo);

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.

Add an IT test to verify that this values is getting propagated from the backend correctly.

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.

3 participants