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: move columns to datasource object for bootstrap data #20203

Merged
merged 2 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions superset/models/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ def username(self) -> str:
def sql_tables(self) -> List[Table]:
return list(ParsedQuery(self.sql).tables)

@property
def columns(self) -> List[Table]:
return self.extra.get("columns", [])

def raise_for_access(self) -> None:
"""
Raise an exception if the user cannot access the resource.
Expand Down
4 changes: 1 addition & 3 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,11 +889,10 @@ def explore(
except (SupersetException, SQLAlchemyError):
datasource_data = dummy_datasource_data

columns: List[Dict[str, Any]] = []
if datasource:
datasource_data["owners"] = datasource.owners_data
if isinstance(datasource, Query):
columns = datasource.extra.get("columns", [])
datasource_data["columns"] = datasource.columns

bootstrap_data = {
"can_add": slice_add_perm,
Expand All @@ -908,7 +907,6 @@ def explore(
"user": bootstrap_user_data(g.user, include_perms=True),
"forced_height": request.args.get("height"),
"common": common_bootstrap_payload(),
"columns": columns,
}
if slc:
title = slc.slice_name
Expand Down