kaxil opened a new pull request, #68103:
URL: https://github.com/apache/airflow/pull/68103

   ## Summary
   
   The common.ai `SQLToolset` metadata tools (`list_tables`, `get_schema`) 
operated against a single `schema`, so an agent over a multi-schema warehouse 
(common on Snowflake) could not discover tables across schemas. With no 
`schema` set and schema-qualified tables, `list_tables` introspected a literal 
`"None"` schema (`SHOW TABLES IN SCHEMA "DB"."None"`) and failed.
   
   `allowed_tables` entries may now be schema-qualified (`"SCHEMA.TABLE"`). 
`list_tables` introspects each referenced schema and returns the matching 
tables fully qualified, and `get_schema` routes each qualified name to its own 
schema.
   
   ## How it works
   
   - Qualified entries are grouped by their schema; `list_tables` queries each 
schema and emits `SCHEMA.TABLE` names, filtered to the allow-list. 
`get_schema("SCHEMA.TABLE")` splits the identifier and passes the schema to the 
hook.
   - Unqualified entries and the allow-all case keep the previous single-schema 
behaviour using the default `schema`, so existing setups are unchanged.
   - Table-name matching is case-insensitive, because databases reflect 
identifiers in their own case (Snowflake reflects unquoted names lowercased) 
and a byte-exact match against uppercase entries would otherwise return 
nothing. The filter is a visibility hint, not access control, so this is safe.
   - Results are de-duplicated by `(schema, table)` so a table reachable both 
qualified and via the default schema is listed once.
   
   ## Usage
   
   ```python
   SQLToolset(
       db_conn_id="snowflake_hq",
       allowed_tables=["MODEL_ASTRO.DEPLOYMENT_IMAGE_DETAILS", 
"MODEL_CRM.SF_ASTRO_ORGS"],
   )
   ```
   
   ## Gotchas
   
   - The schema name passed to the database must match its own identifier 
casing (uppercase on Snowflake, lowercase on Postgres); case-insensitive 
matching covers the allow-list filter against reflected names, not the schema 
lookup itself.
   - Cross-database tables are out of scope: use a separate toolset whose 
connection points at that database.
   


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