no-hup opened a new pull request, #45887: URL: https://github.com/apache/superset/pull/45887
### SUMMARY Listing a schema's tables (`GET /api/v1/database/<id>/tables/`) calls `get_datasources_accessible_by_user` once for tables, once for views and once for materialized views. Each call looks up the user's database, catalog, schema and dataset grants again, so for a user with dataset-level access the same permission queries run three times. This filters all three lists in one call and splits the result. The filter works per name, so the output doesn't change. For a user with `datasource_access` on one table, one listing went from 41 SQL statements to 23 (SQLite, counted with a `before_cursor_execute` listener). | | SQL statements per listing | |---|---| | master | 41 | | this branch | 23 | ### TESTING INSTRUCTIONS `pytest tests/unit_tests/commands/databases/tables_test.py` — passes. The existing tests mocked three calls; they now assert a single call with every name. The new `test_tables_resolve_permissions_once` runs the real filter and checks the grants are looked up once per listing. It fails on master (9 lookups instead of 3). `ruff check` and `ruff format --check` are clean. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
