-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
Changes from 7 commits
1618903
944df5c
23dc294
fd9290a
03059e8
5e7d979
9023b48
c5a9797
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 |
---|---|---|
|
@@ -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 commentThe 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 commentThe 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 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. gotcha! thank you |
||
latest_partition=True, | ||
) | ||
except NoSuchTableError: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. thank you! |
||
""" | ||
Database API: Test get select star with datasource access | ||
""" | ||
table = SqlaTable( | ||
schema="main", table_name="ab_permission", database=get_main_database() | ||
) | ||
db.session.add(table) | ||
db.session.commit() | ||
|
||
tmp_table_perm = security_manager.find_permission_view_menu( | ||
"datasource_access", table.get_perm() | ||
) | ||
gamma_role = security_manager.find_role("Gamma") | ||
security_manager.add_permission_role(gamma_role, tmp_table_perm) | ||
|
||
self.login(GAMMA_USERNAME) | ||
main_db = get_main_database() | ||
uri = f"api/v1/database/{main_db.id}/select_star/ab_permission/" | ||
rv = self.client.get(uri) | ||
self.assertEqual(rv.status_code, 200) | ||
|
||
# rollback changes | ||
security_manager.del_permission_role(gamma_role, tmp_table_perm) | ||
db.session.delete(table) | ||
db.session.delete(main_db) | ||
db.session.commit() | ||
|
||
def test_get_select_star_not_found_database(self): | ||
""" | ||
Database API: Test get select star not found database | ||
|
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.
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!