Skip to content

refactor: resolve BigQuery schema on workers - #4638

Open
fbiville wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
fbiville:neo4j/bq-schema-in-workers
Open

fbiville wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
fbiville:neo4j/bq-schema-in-workers

Conversation

@fbiville

Copy link
Copy Markdown
Collaborator

Resolve the BigQuery schema on workers, so that starting the template no longer requires a launcher-side BigQuery dry-run or BigQuery permissions on the launch identity.

BigQueryRowParser converts records using the TableSchema supplied by the reader at execution time.
RuntimeSchemaRowCoder carries that schema with each element, encoding it with Beam's portable schema protobuf and caching it in an LRU fashion. The pipeline propagates the coder with setCoder instead of setRowSchema.

Resolve the BigQuery schema on workers, so that starting the template no longer
requires a launcher-side BigQuery dry-run or BigQuery permissions on the launch
identity.

`BigQueryRowParser` converts records using the `TableSchema` supplied by the
reader at execution time.
`RuntimeSchemaRowCoder` carries that schema with each element, encoding it
with Beam's portable schema protobuf and caching it in an LRU fashion.
The pipeline propagates the coder with `setCoder` instead of `setRowSchema`.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! 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 refactors the BigQuery data ingestion process to resolve schemas at execution time on workers rather than at pipeline construction time. By moving schema resolution to the worker, the pipeline no longer requires a launcher-side dry-run, which removes the need for BigQuery permissions on the launch identity. This is achieved through a custom row parser and a new coder that carries the schema with each element, significantly enhancing the flexibility and security of the BigQuery-to-Neo4j integration.

Highlights

  • Worker-side Schema Resolution: Introduced BigQueryRowParser to resolve BigQuery schemas directly on workers, eliminating the need for launcher-side dry-runs and associated BigQuery permissions.
  • Runtime Schema Coder: Implemented RuntimeSchemaRowCoder to propagate schemas alongside data elements using portable protobuf encoding, ensuring robust decoding without build-time schema information.
  • Pipeline Refactoring: Updated BqQueryToRow and related pipeline runners to utilize the new parser and coder, simplifying the pipeline graph and improving compatibility.
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 the 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 counterproductive. You can react with 👍 and 👎 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.

Footnotes

  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. ↩

@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 BigQueryRowParser and RuntimeSchemaRowCoder to resolve and carry BigQuery schemas at pipeline execution time on the workers, removing the need for launcher-side BigQuery connectivity. Feedback focuses on optimizing RuntimeSchemaRowCoder to prevent severe global lock contention under high throughput by replacing the synchronized LinkedHashMap caches with ConcurrentHashMap and a custom size-limiting eviction helper. Additionally, it is recommended to simplify the stream reading in readFully using Guava's ByteStreams.readFully utility.

@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.73%. Comparing base (86a5380) to head (5035bc1).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...v2/neo4j/providers/bigquery/BigQueryRowParser.java 0.00% 14 Missing ⚠️
...teleport/v2/neo4j/utils/RuntimeSchemaRowCoder.java 80.35% 10 Missing and 1 partial ⚠️
...port/v2/neo4j/providers/bigquery/BqQueryToRow.java 0.00% 5 Missing ⚠️

❌ Your patch check has failed because the patch coverage (62.50%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@              Coverage Diff              @@
##               main    #4638       +/-   ##
=============================================
+ Coverage     37.79%   59.73%   +21.94%     
- Complexity      521     7936     +7415     
=============================================
  Files           197     1125      +928     
  Lines         12031    72803    +60772     
  Branches       1238     8857     +7619     
=============================================
+ Hits           4547    43489    +38942     
- Misses         7110    26412    +19302     
- Partials        374     2902     +2528     
Components Coverage Δ
spanner-templates 84.03% <ø> (∅)
spanner-import-export 72.72% <ø> (∅)
spanner-live-forward-migration 87.64% <ø> (∅)
spanner-live-reverse-replication 79.93% <ø> (∅)
spanner-bulk-migration 88.28% <ø> (∅)
gcs-spanner-dv 86.56% <ø> (∅)
Files with missing lines Coverage Δ
.../v2/neo4j/templates/Neo4jImportPipelineRunner.java 80.29% <100.00%> (ø)
...t/v2/neo4j/transforms/Neo4jRowWriterTransform.java 84.12% <100.00%> (ø)
...port/v2/neo4j/providers/bigquery/BqQueryToRow.java 0.00% <0.00%> (ø)
...teleport/v2/neo4j/utils/RuntimeSchemaRowCoder.java 80.35% <80.35%> (ø)
...v2/neo4j/providers/bigquery/BigQueryRowParser.java 0.00% <0.00%> (ø)

... and 948 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@fbiville fbiville added the improvement Making existing code better label Nov 26, 2026

@nord-erik nord-erik 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.

lgtm at least, but gemini might have some quick wins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Making existing code better size/XL

2 participants