Skip to content

[yaml] - Expose ReadFromBigQuery row_restriction option in BigQueryToLakehouse - #4660

Draft
derrickaw wants to merge 3 commits into
mainfrom
yaml-drift/bigquery-row-restriction
Draft

derrickaw wants to merge 3 commits into
mainfrom
yaml-drift/bigquery-row-restriction

Conversation

@derrickaw

Copy link
Copy Markdown
Contributor

Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria:

  • The PR resolves YAML blueprint parameter drift tracked in YAML Blueprint Config Parameter Drift Report #4425 against the published Apache Beam YAML Transform Index
  • Any new/updated blueprint parameter preserves lossless Dataflow Job Builder Form loading and round-tripping (or is paired 1:1 with its companion Job Builder form update)
  • Java template interfaces (generate_yaml_java_templates.py), Spotless, Checkstyle, and unit tests have been verified

If you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :)

Part of #4425 (#4425).

Summary

Exposes the optional row_restriction parameter on ReadFromBigQuery in BigQueryToLakehouse.yaml:

  • Adds optional rowRestriction parameter (order: 2) to bigquery_read_options in yaml/src/main/python/options/bigquery_options.yaml matching Apache Beam's ReadFromBigQuery.row_restriction specification (optional SQL WHERE-style filter expression, up to 1 MB, no aggregates).
  • Wires row_restriction: {{ rowRestriction }} inside a {% if rowRestriction %} guard in yaml/src/main/yaml/BigQueryToLakehouse.yaml so existing jobs that omit rowRestriction render identically.
  • Regenerates yaml/src/main/java/com/google/cloud/teleport/templates/yaml/BigQueryToLakehouseYaml.java via generate_yaml_java_templates.py.

Verification

  • Verified Jinja/YAML rendering when rowRestriction is omitted, empty string, and populated with SQL filter expressions (including single and double quotes).
  • Verified generate_yaml_java_templates.py output, generate_yaml_java_templates_test.py (5/5), Spotless, Checkstyle (0 violations), and mvn test-compile -pl yaml -am.
@derrickaw derrickaw added the addition New feature or request label Dec 1, 2026
@derrickaw

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 introduces the lakehouseSortFields parameter to the ParquetToLakehouse template, enabling users to define the sort order when creating new tables. The changes span the Java template interface, the YAML options configuration, and the pipeline template definition. The reviewer correctly noted a mismatch between the pull request's title/description and the actual code changes, which should be corrected to accurately reflect the addition of sorting fields.


@TemplateParameter.Text(
order = 14,
name = "lakehouseSortFields",

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.

medium

There is a mismatch between the pull request title/description (which mention exposing row_restriction in BigQueryToLakehouse) and the actual code changes in this PR (which add lakehouseSortFields to ParquetToLakehouse).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 7c422b8 — the branch now contains strictly the BigQueryToLakehouse row_restriction changes matching the PR title and description.

@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.99%. Comparing base (44c10f1) to head (7c422b8).

❗ There is a different number of reports uploaded between BASE (44c10f1) and HEAD (7c422b8). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (44c10f1) HEAD (7c422b8)
3 1
Additional details and impacted files
@@              Coverage Diff              @@
##               main    #4660       +/-   ##
=============================================
- Coverage     59.72%   37.99%   -21.74%     
+ Complexity     8220      533     -7687     
=============================================
  Files          1122      197      -925     
  Lines         72762    12055    -60707     
  Branches       8855     1239     -7616     
=============================================
- Hits          43459     4580    -38879     
+ Misses        26402     7100    -19302     
+ Partials       2901      375     -2526     
Components Coverage Δ
spanner-templates ∅ <ø> (∅)
spanner-import-export ∅ <ø> (∅)
spanner-live-forward-migration ∅ <ø> (∅)
spanner-live-reverse-replication ∅ <ø> (∅)
spanner-bulk-migration ∅ <ø> (∅)
gcs-spanner-dv ∅ <ø> (∅)
see 947 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.
@derrickaw

Copy link
Copy Markdown
Contributor Author

/gemini review

@pull-request-size pull-request-size Bot added size/M and removed size/S labels Dec 1, 2026

@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 an optional rowRestriction parameter to the BigQuery to Lakehouse YAML template, allowing users to specify a SQL text filtering statement when reading from BigQuery. This parameter is added to the Java interface, the Python options configuration, and the Jinja-templated YAML pipeline definition. The reviewer suggested quoting the rowRestriction variable inside the Jinja template (row_restriction: "{{ rowRestriction }}") to ensure it is properly parsed as a string and to prevent potential validation or parsing errors.

fields: {{ fields }}
{% endif %}
{% if rowRestriction %}
row_restriction: {{ rowRestriction }}

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.

medium

In Jinja-templated YAML configurations, optional parameters like rowRestriction should be wrapped in {% if %} blocks. This ensures that both unset and empty-string inputs omit the key cleanly, preventing validation or parsing errors from empty values, while also ensuring the string is properly quoted.

{% if rowRestriction %}
        row_restriction: "{{ rowRestriction }}"
{% endif %}
References
  1. In Jinja-templated YAML configurations, wrap optional parameters in {% if %} blocks to ensure that both unset and empty-string inputs omit those keys cleanly, preventing validation or parsing errors from empty values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

row_restriction is already wrapped in {% if rowRestriction %} ... {% endif %} here. It is intentionally left unquoted (matching filter: {{ filter }} and query: {{ query }} across the other SQL/Iceberg YAML blueprints) because BigQuery SQL expressions can legitimately contain double-quoted string literals (e.g. status = "ACTIVE"), which would cause a YAML syntax error inside double quotes.

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

Labels

addition New feature or request size/M

1 participant