Repository navigation
Conversation
… pass TablesDatabaseCommand called get_datasources_accessible_by_user once per list. Each call resolves the user's database, catalog, schema and datasource grants from scratch, so listing a schema ran the same permission queries three times. Filter the three lists with one call. For a user with only dataset-level access, one table listing goes from 41 statements to 23 on SQLite, with the same result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45887 +/- ##
===========================================
+ Coverage 65.62% 84.71% +19.09%
===========================================
Files 3069 3069
Lines 205661 205665 +4
Branches 48336 48336
===========================================
+ Hits 134955 174222 +39267
+ Misses 67625 28150 -39475
- Partials 3081 3293 +212
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Listing a schema's tables (
GET /api/v1/database/<id>/tables/) callsget_datasources_accessible_by_useronce 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_accesson one table, one listing went from 41 SQL statements to 23 (SQLite, counted with abefore_cursor_executelistener).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_onceruns the real filter and checks the grants are looked up once per listing. It fails on master (9 lookups instead of 3).ruff checkandruff format --checkare clean.ADDITIONAL INFORMATION
🤖 Generated with Claude Code