fix(agents): return tables from all databases in get_usable_table_names#12411
fix(agents): return tables from all databases in get_usable_table_names#12411chon3806 wants to merge 2 commits into
Conversation
The result_tables list was being reset on every iteration of the databases loop, so when an agent was configured with tables from multiple data sources (e.g. data.tables = ['db1.*', 'db2.*']), only the tables from the last iterated database were returned. Move the reset out of the loop so all matching tables across all databases are accumulated.
|
All contributors have signed the CLA ✍️ ✅ |
EntelligenceAI PR SummaryRemoves dead code in the SQL toolkit and adds unit test coverage for
Confidence Score: 5/5 - Safe to MergeSafe to merge — this PR removes a dead Key Findings:
Files requiring special attention
|
Adds an additional regression test proving that with tables=['db1.users', 'db2.*'] the match() filter still correctly restricts db1 to the listed table while expanding db2 fully.
|
I have read the CLA Document and I hereby sign the CLA |
|
thank you!! can you please create a pull request in github.com/mindsdb/engine |
Description
In
MindsDBQuery.get_usable_table_names, theresult_tableslist is reset to[]on every iteration of thefor db_name in self.tables.databases:loop. As a result, when an agent is configured with tables from more than one data source (e.g.data = {\"tables\": [\"db1.*\", \"db2.*\"]}), only the tables from the last iterated database are ever returned. Tables from earlier databases are silently dropped.This affects:
AgentsController.check_agent_data(called viaget_usable_table_names(lazy=False)during agent creation), which can spuriously fail validation.The fix is a one-line change: move the
result_tables = []initialization out of the per-database loop so matching tables are accumulated across all configured databases.A unit test (
tests/unit/interfaces/agents/test_sql_toolkit.py) is added covering:Type of change
Verification Process
tests/unit/interfaces/agents/test_sql_toolkit.pypytest tests/unit/interfaces/agents/test_sql_toolkit.py -vdata = {\"tables\": [\"db1.*\", \"db2.*\"]}and confirm tables from both databases are listed.Checklist