-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
fix: handle empty catalog when DB supports them #29840
Conversation
I just put this in draft mode whilst it doesn't have a title/description :) Best of luck with whatever it is! :D |
013d840
to
5e7d979
Compare
c03577f
to
9023b48
Compare
@@ -52,7 +52,7 @@ | |||
def fetch_files_github_api(url: str): # type: ignore | |||
"""Fetches data using GitHub API.""" | |||
req = Request(url) | |||
req.add_header("Authorization", f"token {GITHUB_TOKEN}") | |||
req.add_header("Authorization", f"Bearer {GITHUB_TOKEN}") |
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.
Note: In most cases, you can use Authorization: Bearer or Authorization: token to pass a token. However, if you are passing a JSON web token (JWT), you must use Authorization: Bearer. [source]
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.
Nice!
@supersetbot label 4.1 |
@@ -1159,7 +1159,7 @@ def select_star( | |||
self.incr_stats("init", self.select_star.__name__) | |||
try: | |||
result = database.select_star( | |||
Table(table_name, schema_name), | |||
Table(table_name, schema_name, database.get_default_catalog()), |
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.
Should catalog be added to the API path as well (when the table is not from the default one)? Not related with this PR, just asking if it's something we need to do.
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.
Yeah, but I I couldn't find any API calls to this endpoint — it seems like we return this in the database request now, instead of calling /select_star/
, which is why I didn't change the code to pass a parameter. I think we should keep this endpoint until the next major version and then get rid of it.
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.
gotcha! thank you
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.
LGTM!
@@ -1563,34 +1563,6 @@ def test_get_select_star_not_allowed(self): | |||
rv = self.client.get(uri) | |||
self.assertEqual(rv.status_code, 404) | |||
|
|||
def test_get_select_star_datasource_access(self): |
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.
Non-blocking comment: would be good if you could mention why these tests were removed.
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.
These tests were poorly written and relied on weird side effects.
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.
thank you!
(cherry picked from commit 39209c2)
@@ -1963,7 +1965,7 @@ class and any keys added via `ExtraCache`. | |||
if self.has_extra_cache_key_calls(query_obj): | |||
sqla_query = self.get_sqla_query(**query_obj) | |||
extra_cache_keys += sqla_query.extra_cache_keys | |||
return extra_cache_keys | |||
return list(set(extra_cache_keys)) |
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.
Why we replace this line? Actually not doing great job in our case related to #31975
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.
This is just a way of deduping the keys, what problems are you having with it?
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.
in our case it break the chart key retreiving !
we've got some logs saying cache retreiving failed !
Query works on sql-lab but crash in chart or dashboard ( works if force refresh as it does not go to cache )
We are using a lot of url_params reading at the dataset execution.
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.
But how does it break? Is there a stacktrace?i
All this is doing is deduping a list. If it's causing errors, the reason must be upstream of this code.
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.
Main error was a 422
with "Error loading data from cache"uwsgi_superset.log:2025-01-23
And a warning like 15:10:33,731:WARNING:superset.common.utils.query_cache_manager:force_cached (QueryContext): value not found for key 8bda314040760dc2b33b861fb943fc52
Flipping this line make verything works.
Maybe the key for cache creation is not deduplicate and we may have some duplicate on the key witch fail retriving
SUMMARY
Handle edge cases when catalog is passed as
null
but the database supports catalog. This happens when "Allow changing catalogs" is disabled in the database. In these cases we need to use the default catalog, so that permissions checks work as expected.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
[Postgres].[superset]
)[Postgres].[superset].[public]
)ADDITIONAL INFORMATION