Skip to content

Commit

Permalink
fix: SHOW is not DML (apache#13464)
Browse files Browse the repository at this point in the history
* fix: SHOW is not DML

* Fix test
  • Loading branch information
betodealmeida authored and Allan Caetano de Oliveira committed May 21, 2021
1 parent e5ce3dd commit c6de0fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,4 +1096,8 @@ def get_extra_params(database: "Database") -> Dict[str, Any]:
@classmethod
def is_readonly_query(cls, parsed_query: ParsedQuery) -> bool:
"""Pessimistic readonly, 100% sure statement won't mutate anything"""
return parsed_query.is_select() or parsed_query.is_explain()
return (
parsed_query.is_select()
or parsed_query.is_explain()
or parsed_query.is_show()
)
4 changes: 3 additions & 1 deletion tests/db_engine_specs/base_engine_spec_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,11 @@ def test_is_readonly():
def is_readonly(sql: str) -> bool:
return BaseEngineSpec.is_readonly_query(ParsedQuery(sql))

assert not is_readonly("SHOW LOCKS test EXTENDED")
assert is_readonly("SHOW LOCKS test EXTENDED")
assert not is_readonly("SET hivevar:desc='Legislators'")
assert not is_readonly("UPDATE t1 SET col1 = NULL")
assert is_readonly("EXPLAIN SELECT 1")
assert is_readonly("SELECT 1")
assert is_readonly("WITH (SELECT 1) bla SELECT * from bla")
assert is_readonly("SHOW CATALOGS")
assert is_readonly("SHOW TABLES")

0 comments on commit c6de0fc

Please sign in to comment.