-
Notifications
You must be signed in to change notification settings - Fork 18k
feat(sqllab): Add cache sqllab sidebar table schema (#32796) #32830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,13 @@ | |
| :param table: Table instance | ||
| :return: Dict table metadata ready for API response | ||
| """ | ||
| # Lazy import to prevent circular dependency | ||
| from superset.extensions import cache_manager | ||
|
Comment on lines
+74
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incomplete circular dependency comment
Tell me moreWhat is the issue?The inline comment about lazy import is too brief and doesn't explain which modules are involved in the circular dependency. Why this mattersFuture maintainers may inadvertently create import problems without understanding which modules are affected. Suggested change ∙ Feature PreviewLazy import to prevent circular dependency between superset.extensions and superset.databases modulesProvide feedback to improve future suggestions💬 Looking for more details? Reply to this comment to chat with Korbit. |
||
| cache_key = f"table_metadata:{database.id}:{table.catalog or ''}:{table.schema or ''}:{table.table}" | ||
| cached_data = cache_manager.schema_cache.get(cache_key) | ||
| if cached_data: | ||
| return cached_data | ||
|
|
||
| keys = [] | ||
| columns = database.get_columns(table) | ||
| primary_key = database.get_pk_constraint(table) | ||
|
|
@@ -94,7 +101,8 @@ | |
| "comment": col.get("comment"), | ||
| } | ||
| ) | ||
| return { | ||
|
|
||
| result = { | ||
| "name": table.table, | ||
| "columns": payload_columns, | ||
| "selectStar": database.select_star( | ||
|
|
@@ -108,6 +116,8 @@ | |
| "indexes": keys, | ||
| "comment": table_comment, | ||
| } | ||
| cache_manager.schema_cache.set(cache_key, result) | ||
| return result | ||
|
|
||
|
|
||
| def make_url_safe(raw_url: str | URL) -> URL: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ineffective Schema Cache Configuration
Tell me more
What is the issue?
The default schema cache configuration is set to use NullCache, which effectively disables caching.
Why this matters
The NullCache setting will prevent any actual caching from happening, defeating the purpose of implementing the schema caching mechanism for faster table metadata retrieval.
Suggested change ∙ Feature Preview
Set a default cache backend that actually performs caching, for example:
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.