Skip to content

Commit

Permalink
fix(sqla): allow 'unknown' type queries in explore view (apache#11365)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenajiang authored and villebro committed Nov 4, 2020
1 parent 8337c93 commit 8417fb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@ def get_from_clause(
raise QueryObjectValidationError(
_("Virtual dataset query cannot consist of multiple statements")
)
if not ParsedQuery(from_sql).is_readonly():
parsed_query = ParsedQuery(from_sql)
if not (parsed_query.is_unknown() or parsed_query.is_readonly()):
raise QueryObjectValidationError(
_("Virtual dataset query must be read-only")
)
Expand Down
3 changes: 3 additions & 0 deletions superset/sql_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def is_select(self) -> bool:
def is_explain(self) -> bool:
return self.stripped().upper().startswith("EXPLAIN")

def is_unknown(self) -> bool:
return self._parsed[0].get_type() == "UNKNOWN"

def is_readonly(self) -> bool:
"""Pessimistic readonly, 100% sure statement won't mutate anything"""
return self.is_select() or self.is_explain()
Expand Down

0 comments on commit 8417fb9

Please sign in to comment.