Skip to content
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 the schema-fetching problem for impala in sql_lab #3906

Merged
merged 4 commits into from Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions superset/db_engine_specs.py
Expand Up @@ -148,6 +148,10 @@ def adjust_database_uri(cls, uri, selected_schema):
def patch(cls):
pass

@classmethod
def get_schema_names(cls, inspector):
return sorted(inspector.get_schema_names())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code calling the function is already sorting, no need to sort here.


@classmethod
def get_table_names(cls, schema, inspector):
return sorted(inspector.get_table_names(schema))
Expand Down Expand Up @@ -1092,6 +1096,12 @@ def convert_dttm(cls, target_type, dttm):
return "{}'".format(dttm.strftime('%Y-%m-%d'))
return "'{}'".format(dttm.strftime('%Y-%m-%d %H:%M:%S'))

@classmethod
def get_schema_names(cls, inspector):
schemas = [row[0] for row in inspector.engine.execute('SHOW SCHEMAS')
if not row[0].startswith('_')]
return schemas


engines = {
o.engine: o for o in globals().values()
Expand Down
3 changes: 2 additions & 1 deletion superset/models/core.py
Expand Up @@ -726,7 +726,8 @@ def all_view_names(self, schema=None, force=False):
return views

def all_schema_names(self):
return sorted(self.inspector.get_schema_names())
schemas = sorted(self.db_engine_spec.get_schema_names(self.inspector))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the affectation, just return directly

return schemas

@property
def db_engine_spec(self):
Expand Down