-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
feat(SIP-95): permissions for catalogs #28317
Conversation
@@ -127,7 +127,7 @@ class BigQueryEngineSpec(BaseEngineSpec): # pylint: disable=too-many-public-met | |||
|
|||
allows_hidden_cc_in_orderby = True | |||
|
|||
supports_catalog = True | |||
supports_catalog = False |
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.
Changing to false here and in other DB engine specs, since the specs should only have it set to true if they implement their own get_default_catalog
. I'll update the DB engine specs in the near future.
should_cache = kwargs.pop("cache", True) | ||
force = kwargs.pop("force", False) | ||
cache_timeout = kwargs.pop("cache_timeout", 0) |
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.
The current way memoized_func
works is that the decorated function needs to take these parameters, even though they are only used by the decorator. This makes the function tightly coupled with the decorator, which is bad design.
I've fixed the decorator to pop these attributes, and removed them from the decorated functions.
48df814
to
02ad2c0
Compare
02ad2c0
to
3026ee8
Compare
9578fdc
to
2e3b467
Compare
d56dafd
to
f4c3734
Compare
07d3c3e
to
89834d0
Compare
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, I vote for db migrations instead of superset init
634a213
to
79fde57
Compare
79fde57
to
570d729
Compare
570d729
to
4caeef7
Compare
""" | ||
Get all schemas from database | ||
|
||
:param inspector: SqlAlchemy inspector | ||
:return: All schemas in the database | ||
""" | ||
return sorted(inspector.get_schema_names()) |
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.
@betodealmeida @dpgaspar et al. the reason I believe this was a sorted list (as opposed to a set) was to ensure the results were always consistently rendered in SQL Lab et al. I don't disagree that a set is a more appropriate container, but it's contents aren't ordered. Maybe we should being using the ordered-set package for improved transparency.
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.
Ah, thanks! I'll update the logic in SQL Lab to show it sorted there then.
SUMMARY
Continuing the work on #22862. This PR:
/catalogs/
under the DB API, to list catalogs.catalog
to the/schemas/
DB API, to specify a non-default catalog.These are all backend changes that shouldn't affect the current behavior of Superset, other than introducing the new permissions. Note that as of today users can query different catalogs in SQL Lab, and even create (virtual) datasets in different catalogs, and our SQL parser is able to handle catalogs correctly; because of that, introducing these new permissions can be considered a security improvement.
In the next PR I'll start working on the UI to expose the catalog functionality, and enabling support for multi-catalog in a given database will be optional and default to false.
One thing that I'm not sure about is when we should rename existing schema permissions from[db].[schema]
to[db].[default-catalog].[schema]
. In this PR I'm doing it when the database gets updated. I don't think doing it in a migration is a good solution, because we'd have to add a new migration every time a DB engine spec is updated to support catalogs. Another option would be to do it duringsuperset init
— @dpgaspar do you have any thoughts here?Edit: added a migration for the schema permissions, done by a helper function, and a comment in the base DB engine spec informing that when
supports_catalog
is set toTrue
a migration is necessary.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
I've updated existing tests, and I'm adding new tests for all the changes. The PR is draft so it's easier to track which changes have been covered with tests.
ADDITIONAL INFORMATION