nikolauspschuetz commented on code in PR #69108:
URL: https://github.com/apache/airflow/pull/69108#discussion_r3488688056
##########
providers/google/tests/unit/google/cloud/transfers/test_gcs_to_bigquery.py:
##########
@@ -2093,6 +2095,35 @@ def
test_src_fmt_configs_and_extra_config_both_applied_with_precedence(self, hoo
assert config["load"]["skipLeadingRows"] == 5
assert config["load"]["columnNameCharacterMap"] == "STRICT"
+ def test_schema_fields_is_templated(self):
+ """Regression test for #31481.
+
+ ``schema_fields`` must be a template field so a templated value (e.g.
an
+ XComArg or Variable resolving to a schema) is rendered at runtime
instead of
+ being passed through verbatim.
+ """
+ assert "schema_fields" in GCSToBigQueryOperator.template_fields
+ assert
GCSToBigQueryOperator.template_fields_renderers["schema_fields"] == "json"
+
+ with DAG(
+ dag_id="test_gcs_to_bq_schema_fields_templating",
+ schedule=None,
+ start_date=datetime(2024, 1, 1),
+ render_template_as_native_obj=True,
Review Comment:
Good question — and you're right that needing a DAG-level setting for one
attribute would be fragile, so I've reworked the test to drop it.
The actual #31481 case passes a `MappedArgument` (from `.expand()`). Such
values resolve via the Resolvable `resolve()` protocol, not Jinja string
rendering, so `render_template_as_native_obj` was never actually required — it
was only an artifact of the old test using a `{{ ... }}` string as a proxy. The
only real bug was `schema_fields` not being in `template_fields`, so the
argument was never resolved and reached BigQuery verbatim.
The test now passes a value that resolves to the schema under an ordinary
DAG (no `render_template_as_native_obj`) and asserts it's resolved at render
time — the precise #31481 scenario, and it fails without the `template_fields`
change. Thanks for catching this!
---
Drafted-by: Claude Code (Opus 4.8) (no human review before posting)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]