get_foreign_keys() missing @reflection.cache causes excessive DESCRIBE TABLE EXTENDED queries
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 90/100
Research direction
Start in base.py at get_foreign_keys() around line 256 and compare it with get_pk_constraint() around line 211, both of which use _describe_table_extended(). Add the missing reflection cache decorator and verify that DESCRIBE TABLE EXTENDED is issued only once per table during repeated reflection.
Written by the indexing model from the issue text.
Description
Summary
get_foreign_keys() is missing the @reflection.cache decorator, causing a fresh DESCRIBE TABLE EXTENDED query to be issued to the SQL warehouse for every table on every reflection call.
Expected behaviour
Like get_pk_constraint(), has_table(), and get_table_comment(), get_foreign_keys() should be cached per-table per-connection so that DESCRIBE TABLE EXTENDED is only executed once per table during a reflection pass.
Actual behaviour
Every call to get_foreign_keys() unconditionally executes:
DESCRIBE TABLE EXTENDED `catalog`.`schema`.`table`
When reflecting schemas with many tables (or when reflection is triggered repeatedly, e.g. on each request in a web application), this produces a large number of redundant warehouse queries.
Root cause
base.py — get_foreign_keys() at line 256 lacks @reflection.cache. Compare with get_pk_constraint() (line 211) which uses the same _describe_table_extended() helper but is correctly decorated.
Fix
Add @reflection.cache to get_foreign_keys().
- Dominant language
- Python
- Stars
- 24
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from databricks/databricks-sqlalchemy
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
databricks/databricks-sqlalchemy#73 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
All issues in databricks/databricks-sqlalchemy
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100