betodealmeida commented on a change in pull request #7358: limit tables/views
returned if schema is not provided
URL:
https://github.com/apache/incubator-superset/pull/7358#discussion_r277853753
##########
File path: superset/views/core.py
##########
@@ -1513,6 +1513,25 @@ def tables(self, db_id, schema, substr,
force_refresh='false'):
table_names = [tn for tn in table_names if substr in tn]
view_names = [vn for vn in view_names if substr in vn]
+ if not schema and database.default_schemas:
+ def is_default_tbl_or_view(tbl_or_view_name, schemas):
Review comment:
You can simplify and optimize this a little bit:
```python
def get_schema(tbl_or_view_name):
return tbl_or_view_name.split('.')[0] if '.' in tbl_or_view_name else
None
schemas = set(database.default_schemas)
schemas.add(g.user.username)
table_names = [tn for tn in table_names if get_schema(tn) in schemas]
view_names = [vn for vn in view_names if get_schema(vn) in schemas]
```
This avoids the nested loop (`for schema in schemas` inside the list
comprehensions).
There's one more problem here is that `g.user.username` is not what we want.
In my case at Lyft, my `g.user.username` is `google_101076032713814560036`, not
`bdealmeida`. I think in most cases we want to use `g.user.email.split('@')[0]`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]