mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
chore: Support SET & SHOW commands as read only SQL commands (#11868)
* Support SET & SHOW commands as read only SQL commands * Move is_readonly definition into the engine spec * Rename & use super() Co-authored-by: bogdan kyryliuk <bogdankyryliuk@dropbox.com>
This commit is contained in:
@@ -23,7 +23,7 @@ import pytest
|
||||
from tests.test_app import app
|
||||
from superset.db_engine_specs.hive import HiveEngineSpec
|
||||
from superset.exceptions import SupersetException
|
||||
from superset.sql_parse import Table
|
||||
from superset.sql_parse import Table, ParsedQuery
|
||||
|
||||
|
||||
def test_0_progress():
|
||||
@@ -234,3 +234,16 @@ def test_get_create_table_stmt() -> None:
|
||||
tblproperties ('skip.header.line.count'=:header_line_count)""",
|
||||
{"delim": ",", "location": "s3a://directory/table", "header_line_count": "101"},
|
||||
)
|
||||
|
||||
|
||||
def test_is_readonly():
|
||||
def is_readonly(sql: str) -> bool:
|
||||
return HiveEngineSpec.is_readonly_query(ParsedQuery(sql))
|
||||
|
||||
assert not is_readonly("UPDATE t1 SET col1 = NULL")
|
||||
assert not is_readonly("INSERT OVERWRITE TABLE tabB SELECT a.Age FROM TableA")
|
||||
assert is_readonly("SHOW LOCKS test EXTENDED")
|
||||
assert is_readonly("SET hivevar:desc='Legislators'")
|
||||
assert is_readonly("EXPLAIN SELECT 1")
|
||||
assert is_readonly("SELECT 1")
|
||||
assert is_readonly("WITH (SELECT 1) bla SELECT * from bla")
|
||||
|
||||
Reference in New Issue
Block a user