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


##########
providers/common/ai/src/airflow/providers/common/ai/operators/llm_sql.py:
##########
@@ -192,10 +216,27 @@ def execute_complete(
         """Resume after human review, re-validating if the reviewer modified 
the SQL."""
         output = self._complete_review(context, generated_output, event, 
decision)
         if output != generated_output:
-            _validate_sql(output, allowed_types=self.allowed_sql_types, 
dialect=self._resolved_dialect)
+            self._check_sql(output)
         self._clear_usage_budget(context)
         return output
 
+    def _check_sql(self, sql: str) -> None:
+        """Validate the statement types of ``sql`` and, when set, the tables 
it may reference."""
+        statements = _validate_sql(sql, allowed_types=self.allowed_sql_types, 
dialect=self._resolved_dialect)
+        if self.allowed_tables is None:
+            return
+        violations = find_allowed_tables_violations(statements, 
canonical_allowed_tables(self.allowed_tables))

Review Comment:
   Added `allowed_functions` with the same semantics as `SQLToolset` 
(case-insensitive, only consulted when `allowed_tables` is set), so the 
existing message is now accurate. 
`test_allowed_functions_permits_unrecognized_functions` covers your 
`json_build_object` and `age` examples, and `age` without it is pinned as 
refused.



##########
providers/common/ai/tests/unit/common/ai/operators/test_llm_sql.py:
##########
@@ -759,6 +759,103 @@ def _make_context(ti_id=None):
 @pytest.mark.skipif(
     not AIRFLOW_V_3_1_PLUS, reason="Human in the loop is only compatible with 
Airflow >= 3.1.0"
 )
+class TestLLMSQLQueryOperatorAllowedTables:

Review Comment:
   Good catch, my mistake. Moved the class above the decorator so the approval 
suite keeps its 3.1 skip, and `test_reviewer_modified_sql_is_checked` now has 
its own skip, in 80e91e559b.



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