Add table information to BigQueryStorageApiInsertError
What is the purpose of the change?
This change adds table identification capabilities to BigQueryStorageApiInsertError to help users identify and troubleshoot errors when using BigQuery Storage Write API,
especially in pipelines that write to multiple tables.
Fixes #36831
What changes are included in this PR?
-
Added
tableUrnfield toBigQueryStorageApiInsertError- Format:
projects/{project}/datasets/{dataset}/tables/{table} - Consistent with
TableDestination.getTableUrn()format
- Format:
-
Added convenience methods with lazy initialization
getProjectId(),getDatasetId(),getTableId()- Uses lazy initialization with caching for optimal performance
-
Updated
BigQueryStorageApiInsertErrorCoder- Encode/decode
tableUrnfield
- Encode/decode
-
Updated all calling sites to pass
tableUrnStorageApiWriteUnshardedRecords.java(3 locations)StorageApiWritesShardedRecords.java(3 locations)StorageApiConvertMessages.java(2 locations)
This makes the API consistent with BigQueryInsertError (used by STREAMING_INSERTS method).
How was this change tested?
- ✅ Local unit tests:
./gradlew :sdks:java:io:google-cloud-platform:test --tests "*StorageApi*"(PASSED) - ✅ Code formatting:
./gradlew :sdks:java:io:google-cloud-platform:spotlessApply(PASSED) - ✅ Verified table information is correctly captured in production pipeline error logs
Was this change documented?
- [x] Code changes are self-documenting
- [ ] Javadoc updated (existing constructors and getters are self-explanatory)
Checklist
- [x] Mentions the appropriate issue:
Fixes #36831 - [ ] Update
CHANGES.md(will add if required by reviewers) - [x] ICLA not required (small contribution)
Summary of Changes
Hello @hekk-kaori-maeda, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly improves the debugging and error handling capabilities for the BigQuery Storage Write API by embedding table identification directly into BigQueryStorageApiInsertError objects. This enhancement allows users to quickly pinpoint which table an error originated from, especially in complex pipelines writing to multiple BigQuery tables, thereby streamlining troubleshooting processes.
Highlights
- Enhanced Error Information: The
BigQueryStorageApiInsertErrorclass now includes atableUrnfield, providing specific table identification for insertion errors. - Convenience Accessors: New methods
getProjectId(),getDatasetId(), andgetTableId()have been added toBigQueryStorageApiInsertErrorfor easy extraction of table components from thetableUrn, utilizing lazy initialization for performance. - Serialization Update: The
BigQueryStorageApiInsertErrorCoderhas been updated to correctly encode and decode the newtableUrnfield, ensuring data integrity across serialization. - Widespread Integration: All relevant calling sites within
StorageApiWriteUnshardedRecords,StorageApiWritesShardedRecords, andStorageApiConvertMessageshave been modified to capture and pass thetableUrnwhen creatingBigQueryStorageApiInsertErrorinstances.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.
Assigning reviewers:
R: @m-trieu for label java.
Note: If you would like to opt out of this review, comment assign to next reviewer.
Available commands:
stop reviewer notifications- opt out of the automated review toolingremind me after tests pass- tag the comment author after tests passwaiting on author- shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
The PR bot will only process comments in the main thread (not review comments).
@hekk-kaori-maeda I really like PR! To be more consistent with BigQueryInsertError please use TableReference as field and expose it.
@stankiewicz
Thank you for the review!
I've updated the implementation to use TableReference instead of String tableUrn, following the pattern used in BigQueryInsertError.
Changes made:
-
Changed to
TableReferencefieldBigQueryStorageApiInsertErrornow usesTableReference tableinstead ofString tableUrn- Removed custom parsing methods (
getProjectId(),getDatasetId(),getTableId()) - Added
getTable()method that returnsTableReference
-
Updated coder to use BigQueryHelpers
encode(): UsesBigQueryHelpers.toTableSpec()to convertTableReference→Stringdecode(): UsesBigQueryHelpers.parseTableSpec()to convertString→TableReference
-
Added null safety checks
- Added null checks in the coder before calling
toTableSpec()andparseTableSpec() - This prevents
NullPointerExceptionwhen table information is unavailable - Ensures pipeline stability even during error handling scenarios
- Added null checks in the coder before calling
-
Updated all calling sites
- All instantiation sites now pass
TableReferencefromTableDestination.getTableReference() - Files updated:
StorageApiWriteUnshardedRecords.java,StorageApiWritesShardedRecords.java,StorageApiConvertMessages.java - Added
TableReferenceimports to modified files
- All instantiation sites now pass
-
Updated toString() method
- Added
tablefield to the string representation for better debugging visibility - Ensures all fields are included in error logs
- Added
Ready for review.
Reminder, please take a look at this pr: @m-trieu
Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:
R: @ahmedabu98 for label java.
Available commands:
stop reviewer notifications- opt out of the automated review toolingremind me after tests pass- tag the comment author after tests passwaiting on author- shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
Reminder, please take a look at this pr: @ahmedabu98
@ahmedabu98 Thank you for the review!
I've added unit tests for BigQueryStorageApiInsertErrorCoder in commit [a933d85].
The tests cover:
- Basic encode/decode with all fields populated
- Encode/decode with null
table - Encode/decode with null
errorMessage - Encode/decode with both nullable fields null
Regarding update compatibility
Since BigQueryStorageApiInsertError is used for error handling and typically not persisted across pipeline updates, I believe the current implementation follows the existing patterns. However, if you'd like me to add backward compatibility (e.g., version flag or field count check), please let me know.
Could you also clarify your comment about "update compatibility"? I wasn't able to find the inline comment.
Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:
R: @kennknowles for label java.
Available commands:
stop reviewer notifications- opt out of the automated review toolingremind me after tests pass- tag the comment author after tests passwaiting on author- shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
Reminder, please take a look at this pr: @kennknowles