Skip to content

Fix BteqOperator declaring template_fields as a bare string - #70862

Merged
potiuk merged 1 commit into
apache:mainfrom
Eason09053360:fix-bteq-template-fields
Aug 1, 2026
Merged

Fix BteqOperator declaring template_fields as a bare string#70862
potiuk merged 1 commit into
apache:mainfrom
Eason09053360:fix-bteq-template-fields

Conversation

@Eason09053360

Copy link
Copy Markdown
Contributor

BteqOperator declared template_fields = "sql". A bare string is a sequence of
characters, so this declares the fields "s", "q" and "l" rather than "sql".

Airflow papers over this in BaseOperator.__init__, which wraps a string
template_fields in a list, but it emits a UserWarning every time a task is
built, and any code reading the class attribute directly — the sphinx
template-fields doc role, dry_run(), _set_xcomargs_dependencies() — still
sees the wrong value.

Declaring it as Sequence[str] = ("sql",) matches every other operator in the
codebase and drops the warning.

The existing test_template_fields asserted the incorrect value, so it is updated
to the corrected one (and a stray print removed).


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

A bare string is a sequence of characters, so "sql" declares the fields
"s", "q" and "l" rather than "sql". Airflow papers over this by wrapping
the string in a list, but it emits a UserWarning every time a task is
built, and any code reading the class attribute directly still sees the
wrong value.

@potiuk potiuk 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.

Good catch. template_fields = "sql" declared three fields — "s", "q" and "l" — since a string is a sequence of characters.

The base operator wraps it at runtime so rendering still worked, but it warned on every task instantiation with "Please update {task_type} accordingly", and anything reading the class attribute before instantiation (the sphinx template-fields doc role, dry_run(), _set_xcomargs_dependencies()) saw the wrong value.

Nice that you also fixed the test — it was asserting == "sql", so it was pinning the bug in place.


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

@potiuk
potiuk merged commit 154e3c8 into apache:main Aug 1, 2026
83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants