pavansai1997 commented on code in PR #76230:
URL: https://github.com/apache/airflow/pull/76230#discussion_r4438891423


##########
providers/common/ai/docs/operators/llm_sql.rst:
##########
@@ -178,6 +178,38 @@ By default, the operator validates generated SQL using an 
allowlist approach:
 You can disable validation with ``validate_sql=False`` or customize the allowed
 statement types with ``allowed_sql_types``.
 
+Restricting the tables a query may reference
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+``table_names`` only selects the schemas shown to the LLM; it does not stop the
+generated SQL from reading other tables. Set ``allowed_tables`` to reject any 
query
+that references a table outside the list:
+
+.. code-block:: python

Review Comment:
   Moved it to `example_llm_sql.py` as `example_llm_sql_allowed_tables`, 
included through `exampleinclude`. It also shows `allowed_functions`.



##########
providers/common/ai/src/airflow/providers/common/ai/operators/llm_sql.py:
##########
@@ -124,6 +135,7 @@ def __init__(
         schema_context: str | None = None,
         validate_sql: bool = True,
         allowed_sql_types: tuple[type[exp.Expr], ...] = DEFAULT_ALLOWED_TYPES,
+        allowed_tables: list[str] | None = None,

Review Comment:
   Static is intended. Since it is a safety control, I would rather it be fixed 
when the Dag is parsed: the empty-list and `validate_sql=False` checks can fail 
at construction, and the list stays out of reach of run-time values such as 
`params` or `dag_run.conf`, which whoever triggers the run can set. A Dag can 
still keep both in step by building them from the same Python list. I noted 
this in the docstring and docs, but happy to make it a template field if you 
would prefer parity with `table_names`.



-- 
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]

Reply via email to