Skip to content

Commit

Permalink
fix: move columns to datasource object for bootstrap data (#20203)
Browse files Browse the repository at this point in the history
* move columns to datasource

* address concerns
  • Loading branch information
hughhhh authored May 31, 2022
1 parent e07ee6c commit 9432c62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit 9432c62

Please sign in to comment.