This is an automated email from the ASF dual-hosted git repository.

shahar1 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 9ecb9929de9 Constrain the Teradata compute-cluster example Dag's 
user-settable Params (#72714)
9ecb9929de9 is described below

commit 9ecb9929de9be2990b02a1fc64fa307f107132a6
Author: Jarek Potiuk <[email protected]>
AuthorDate: Mon Sep 21 22:25:27 2026 +0200

    Constrain the Teradata compute-cluster example Dag's user-settable Params 
(#72714)
---
 .../teradata/example_teradata_compute_cluster.py   | 50 ++++++++++++++--------
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git 
a/providers/teradata/tests/system/teradata/example_teradata_compute_cluster.py 
b/providers/teradata/tests/system/teradata/example_teradata_compute_cluster.py
index 92366b55437..fdbd8ddffa1 100644
--- 
a/providers/teradata/tests/system/teradata/example_teradata_compute_cluster.py
+++ 
b/providers/teradata/tests/system/teradata/example_teradata_compute_cluster.py
@@ -45,53 +45,67 @@ except ImportError:
 ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
 DAG_ID = "example_teradata_computer_cluster"
 
+# The operators below build Teradata DDL by interpolating these names into SQL 
text.
+# Object names cannot be passed as bind parameters, so anything reaching them 
must be
+# constrained where it is declared. Params are settable by whoever triggers 
the Dag --
+# a lower-trust role than the Dag author -- so every Param here is either 
restricted to
+# a closed set of values (`enum`) or to an identifier shape (`pattern`).
+#
+# `teradata_conn_id` and `compute_attribute` are deliberately NOT Params: the 
first
+# selects which credentials the task runs under, and the second is a free-form 
option
+# string with no safe identifier shape. Neither belongs under trigger-time 
control.
+TERADATA_CONN_ID = "teradata_lake"
+COMPUTE_ATTRIBUTE = "MIN_COMPUTE_COUNT(1) MAX_COMPUTE_COUNT(5) 
INITIALLY_SUSPENDED('FALSE')"
+
+# Unquoted Teradata object name: a letter followed by letters, digits or 
underscores.
+OBJECT_NAME_PATTERN = "^[A-Za-z][A-Za-z0-9_]{0,127}$"
+
 with DAG(
     dag_id=DAG_ID,
     start_date=datetime.datetime(2020, 2, 2),
     schedule="@once",
     catchup=False,
-    default_args={"teradata_conn_id": "teradata_lake"},
+    default_args={"teradata_conn_id": TERADATA_CONN_ID},
     render_template_as_native_obj=True,
     params={
         "compute_group_name": Param(
             "compute_group_test",
             type="string",
+            pattern=OBJECT_NAME_PATTERN,
             title="Compute cluster group Name:",
             description="Enter compute cluster group name.",
         ),
         "compute_profile_name": Param(
             "compute_profile_test",
             type="string",
+            pattern=OBJECT_NAME_PATTERN,
             title="Compute cluster profile Name:",
             description="Enter compute cluster profile name.",
         ),
         "query_strategy": Param(
             "STANDARD",
             type="string",
+            enum=["STANDARD", "ANALYTIC"],
             title="Compute cluster instance type:",
             description="Enter compute cluster instance type. Valid values are 
STANDARD, ANALYTIC",
         ),
         "compute_map": Param(
             "TD_COMPUTE_XSMALL",
             type="string",
+            pattern=OBJECT_NAME_PATTERN,
             title="Compute Map Name:",
             description="Enter compute cluster compute map name.",
         ),
-        "compute_attribute": Param(
-            "MIN_COMPUTE_COUNT(1) MAX_COMPUTE_COUNT(5) 
INITIALLY_SUSPENDED('FALSE')",
-            type="string",
-            title="Compute cluster compute attribute:",
-            description="Enter compute cluster compute attribute values.",
-        ),
-        "teradata_conn_id": Param(
-            "teradata_lake",
-            type="string",
-            title="Teradata ConnectionId:",
-            description="Enter Teradata connection id.",
+        "delete_compute_group": Param(
+            False,
+            type="boolean",
+            title="Delete the compute group on decommission:",
+            description="Whether decommissioning also deletes the compute 
group.",
         ),
         "timeout": Param(
             20,
             type="integer",
+            minimum=1,
             title="Timeout:",
             description="Time elapsed before the task times out and fails. 
Timeout is in minutes.",
         ),
@@ -102,11 +116,11 @@ with DAG(
         task_id="compute_cluster_provision_operation",
         compute_profile_name="{{ params.compute_profile_name }}",
         compute_group_name="{{ params.compute_group_name }}",
-        teradata_conn_id="{{ params.teradata_conn_id }}",
+        teradata_conn_id=TERADATA_CONN_ID,
         timeout="{{ params.timeout }}",
         query_strategy="{{ params.query_strategy }}",
         compute_map="{{ params.compute_map }}",
-        compute_attribute="{{ params.compute_attribute }}",
+        compute_attribute=COMPUTE_ATTRIBUTE,
     )
     # [END teradata_vantage_lake_compute_cluster_provision_howto_guide]
     # [START teradata_vantage_lake_compute_cluster_suspend_howto_guide]
@@ -114,7 +128,7 @@ with DAG(
         task_id="compute_cluster_suspend_operation",
         compute_profile_name="{{ params.compute_profile_name }}",
         compute_group_name="{{ params.compute_group_name }}",
-        teradata_conn_id="{{ params.teradata_conn_id }}",
+        teradata_conn_id=TERADATA_CONN_ID,
         timeout="{{ params.timeout }}",
     )
     # [END teradata_vantage_lake_compute_cluster_suspend_howto_guide]
@@ -123,7 +137,7 @@ with DAG(
         task_id="compute_cluster_resume_operation",
         compute_profile_name="{{ params.compute_profile_name }}",
         compute_group_name="{{ params.compute_group_name }}",
-        teradata_conn_id="{{ params.teradata_conn_id }}",
+        teradata_conn_id=TERADATA_CONN_ID,
         timeout="{{ params.timeout }}",
     )
     # [END teradata_vantage_lake_compute_cluster_resume_howto_guide]
@@ -132,8 +146,8 @@ with DAG(
         task_id="compute_cluster_decommission_operation",
         compute_profile_name="{{ params.compute_profile_name }}",
         compute_group_name="{{ params.compute_group_name }}",
-        delete_compute_group=bool("{{ params.delete_compute_group }}"),
-        teradata_conn_id="{{ params.teradata_conn_id }}",
+        delete_compute_group="{{ params.delete_compute_group }}",  # type: 
ignore[arg-type]
+        teradata_conn_id=TERADATA_CONN_ID,
         timeout="{{ params.timeout }}",
     )
     # [END teradata_vantage_lake_compute_cluster_decommission_howto_guide]

Reply via email to