Skip to content

feat(bigquery): add ArrowDeserializer helper utility - #13943

Merged
jinseopkim0 merged 40 commits into
mainfrom
feat-bigquery-arrow-deserializer
Sep 14, 2026
Merged

jinseopkim0 merged 40 commits into
mainfrom
feat-bigquery-arrow-deserializer

Conversation

@jinseopkim0

@jinseopkim0 jinseopkim0 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Adds the ArrowDeserializer class which handles decoding serialized Arrow schemas and record batches into standard FieldValueList rows.

@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 introduces the ArrowDeserializer class to convert Apache Arrow schemas and record batches into BigQuery schemas and FieldValueList rows. Feedback on the implementation highlights several critical issues: a potential native memory leak if vector creation fails, a bug in repeated record deserialization where subfields are omitted, missing defensive checks for schema and size mismatches, and an inefficient timestamp conversion that should cast to TimeStampVector and handle different time units.

@jinseopkim0
jinseopkim0 force-pushed the feat-bigquery-arrow-deserializer branch from e149afc to 796b77f Compare August 7, 2026 18:52
@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist 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 introduces comprehensive documentation (including developer, user, and storage API guides) and adds support for Apache Arrow serialization and deserialization in the BigQuery client and JDBC driver. It also introduces a centralized type registry and temporal utilities for optimized type coercion. The review feedback highlights several critical improvements: optimizing memory allocation and preventing resource leaks in ArrowDeserializer by passing the BufferAllocator and using proper try-finally blocks; avoiding precision loss in timestamp formatting by using integer division; ensuring that the new Arrow configuration options are actually transmitted to the BigQuery backend by serializing them in QueryJobConfiguration.toPb(); and adhering to timezone handling rules by using legacy Calendar manipulation and LocalTime.ofNanoOfDay for java.sql.Time conversions.

@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist 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 introduces Apache Arrow serialization options and deserialization support to the BigQuery client library, alongside extensive documentation and optimized type registry utilities for the JDBC driver. The review feedback highlights critical issues where the new Arrow configuration fields in QueryJobConfiguration are not serialized or deserialized in toPb() and fromPb(), rendering them ineffective. Additionally, the reviewer recommends reusing a single BufferAllocator in ArrowDeserializer to avoid high allocation overhead, ensuring exception-safe LIFO cleanup of FieldVector instances to prevent memory leaks, and using a timezone-aware manual conversion when converting java.sql.Time to java.time.LocalTime to preserve millisecond precision.

@jinseopkim0
jinseopkim0 force-pushed the feat-bigquery-arrow-deserializer branch from 9056c4c to 9ddd9d2 Compare August 7, 2026 19:16
@jinseopkim0
jinseopkim0 force-pushed the feat-bigquery-arrow-deserializer branch from 9ddd9d2 to 712b972 Compare August 7, 2026 19:19
@jinseopkim0 jinseopkim0 added kokoro:force-run Add this label to force Kokoro to re-run the tests. kokoro:run Add this label to force Kokoro to re-run the tests. labels Aug 7, 2026
@jinseopkim0
jinseopkim0 force-pushed the feat-bigquery-arrow-deserializer branch 4 times, most recently from f139009 to dd8bc5a Compare August 10, 2026 15:25
@jinseopkim0 jinseopkim0 added kokoro:force-run Add this label to force Kokoro to re-run the tests. kokoro:run Add this label to force Kokoro to re-run the tests. and removed kokoro:force-run Add this label to force Kokoro to re-run the tests. kokoro:run Add this label to force Kokoro to re-run the tests. labels Aug 10, 2026
@jinseopkim0
jinseopkim0 marked this pull request as ready for review August 11, 2026 19:19
@jinseopkim0
jinseopkim0 requested review from a team as code owners August 11, 2026 19:19
@jinseopkim0
jinseopkim0 requested a review from lqiu96 August 11, 2026 19:19
Base automatically changed from feat-bigquery-arrow-config to main August 12, 2026 14:36

@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 introduces ArrowDeserializer and ArrowPojoUtils along with comprehensive unit tests to handle the deserialization of Apache Arrow IPC record batches and schemas into BigQuery Veneer objects. The feedback suggests optimizing loadArrowRows by returning early when the stream is exhausted to prevent unnecessary off-heap memory allocations. Additionally, it recommends falling back to string conversion for unrecognized TIME vector types to avoid silently defaulting to zero.

@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist 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 introduces ArrowDeserializer and ArrowPojoUtils along with their corresponding tests to handle the deserialization of Apache Arrow IPC record batches and schemas into BigQuery Veneer objects. The feedback highlights a critical issue in ArrowDeserializer.arrowVectorToFieldValue where null RECORD or REPEATED fields incorrectly return a primitive null FieldValue, which will cause an IllegalStateException in client code. The reviewer suggests adjusting the deserialization logic to return appropriate empty or null-valued structured attributes instead, and adding a corresponding unit test to verify this behavior.

@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist 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 introduces ArrowDeserializer and ArrowPojoUtils to deserialize Apache Arrow IPC record batches and schemas into BigQuery Veneer objects, accompanied by comprehensive unit tests. Feedback was provided to optimize performance in ArrowDeserializer.arrowVectorToFieldValue by passing individual field components directly rather than instantiating new Field and Field.Builder objects for every element of a repeated field, thereby reducing GC pressure.

@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist 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 introduces ArrowDeserializer and ArrowPojoUtils to handle the deserialization of Apache Arrow IPC record batches and the conversion of Arrow schemas into BigQuery Veneer objects, accompanied by comprehensive unit tests. The review feedback suggests adding a validation check in ArrowPojoUtils.getSubFields to throw an IllegalArgumentException if an Arrow Struct field has no children, as BigQuery does not support empty RECORD (STRUCT) fields.

@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist 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 introduces ArrowDeserializer and ArrowPojoUtils to handle the deserialization of Apache Arrow IPC record batches and schema definitions into BigQuery Veneer objects, accompanied by comprehensive unit tests. The review feedback suggests two key improvements in ArrowDeserializer: first, replacing structVector.size() with structVector.getChildVectors().size() to clarify that it refers to child fields rather than row count; second, optimizing performance by using specific vector primitive getters instead of vector.getObject(rowIndex) to avoid boxing and object allocation overhead.

@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist 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 introduces ArrowDeserializer and ArrowPojoUtils to handle the deserialization of Apache Arrow record batches and schemas into BigQuery Veneer objects, complete with comprehensive unit tests. The review feedback suggests addressing boundary condition checks in loadArrowRows when maxResults is reached to prevent returning incorrect continuation signals. Additionally, it recommends using toPlainString() for BigDecimal values to avoid scientific notation formatting, ensuring compatibility with BigQuery's expected decimal format.

@jinseopkim0

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist 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 introduces two new internal helper classes, ArrowDeserializer and ArrowPojoUtils, along with comprehensive unit tests. ArrowDeserializer manages Arrow vector memory and deserializes IPC record batches into BigQuery Veneer objects, while ArrowPojoUtils handles the conversion of Apache Arrow POJO definitions (such as Schema, Field, and ArrowType) into BigQuery Veneer objects. There are no review comments, and we have no feedback to provide.

@jinseopkim0
jinseopkim0 requested a review from lqiu96 September 12, 2026 00:55

@lqiu96 lqiu96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Added a few comments but nothing major from what I can see.

There is a lot of conversion logic and unit tests to confirm the behavior. We may run into some issues when we run ITs against real calls, but we can always fix that when we get there.

@jinseopkim0
jinseopkim0 merged commit d9a298b into main Sep 14, 2026
231 of 232 checks passed
@jinseopkim0
jinseopkim0 deleted the feat-bigquery-arrow-deserializer branch September 14, 2026 20:53
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