This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 154e3c8cdfc Fix BteqOperator declaring template_fields as a bare
string (#70862)
154e3c8cdfc is described below
commit 154e3c8cdfc2477dc5bd0dbb2b7015475bd1ce97
Author: Y-C <[email protected]>
AuthorDate: Sat Aug 1 09:41:33 2026 +0800
Fix BteqOperator declaring template_fields as a bare string (#70862)
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.
Co-authored-by: Eason09053360
<[email protected]>
---
providers/teradata/src/airflow/providers/teradata/operators/bteq.py | 3 ++-
providers/teradata/tests/unit/teradata/operators/test_bteq.py | 3 +--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git
a/providers/teradata/src/airflow/providers/teradata/operators/bteq.py
b/providers/teradata/src/airflow/providers/teradata/operators/bteq.py
index 2557a525a1b..847ff1734c9 100644
--- a/providers/teradata/src/airflow/providers/teradata/operators/bteq.py
+++ b/providers/teradata/src/airflow/providers/teradata/operators/bteq.py
@@ -17,6 +17,7 @@
# under the License.
from __future__ import annotations
+from collections.abc import Sequence
from typing import TYPE_CHECKING, Literal
from airflow.providers.teradata.utils.bteq_util import (
@@ -75,7 +76,7 @@ class BteqOperator(BaseOperator):
:param timeout_rc: Return code to use if the BTEQ execution fails due to a
timeout. To allow DAG execution to continue after a timeout, include this value
in `bteq_quit_rc`. If not specified, a timeout will raise an exception and stop
the DAG.
"""
- template_fields = "sql"
+ template_fields: Sequence[str] = ("sql",)
ui_color = "#ff976d"
def __init__(
diff --git a/providers/teradata/tests/unit/teradata/operators/test_bteq.py
b/providers/teradata/tests/unit/teradata/operators/test_bteq.py
index a099576960f..86bedcf8438 100644
--- a/providers/teradata/tests/unit/teradata/operators/test_bteq.py
+++ b/providers/teradata/tests/unit/teradata/operators/test_bteq.py
@@ -144,8 +144,7 @@ class TestBteqOperator:
def test_template_fields(self):
# Verify template fields are defined correctly
- print(BteqOperator.template_fields)
- assert BteqOperator.template_fields == "sql"
+ assert BteqOperator.template_fields == ("sql",)
def test_execute_raises_if_no_sql_or_file(self):
op = BteqOperator(task_id="fail_case", teradata_conn_id="td_conn")