Make schema name for the CTA queries and limit configurable (#8867)

* Make schema name configurable

Fixing unit tests

Fix table quoting

Mypy

Split tests out for sqlite

Grant more permissions for mysql user

Postgres doesn't support if not exists

More logging

Commit for table creation

Priviliges for postgres

Update tests

Resolve comments

Lint

No limits for the CTA queries if configures

* CTA -> CTAS and dict -> {}

* Move database creation to the .travis file

* Black

* Move tweaks to travis db setup

* Remove left over version

* Address comments

* Quote table names in the CTAS queries

* Pass tmp_schema_name for the query execution

* Rebase alembic migration

* Switch to python3 mypy

* SQLLAB_CTA_SCHEMA_NAME_FUNC -> SQLLAB_CTAS_SCHEMA_NAME_FUNC

* Black
This commit is contained in:
Bogdan
2020-03-03 09:52:20 -08:00
committed by GitHub
parent 26e916e46b
commit 4e1fa95035
15 changed files with 342 additions and 66 deletions

View File

@@ -229,22 +229,27 @@ class SupersetTestCase(TestCase):
query_limit=None,
database_name="examples",
sql_editor_id=None,
select_as_cta=False,
tmp_table_name=None,
):
if user_name:
self.logout()
self.login(username=(user_name or "admin"))
dbid = self._get_database_by_name(database_name).id
json_payload = {
"database_id": dbid,
"sql": sql,
"client_id": client_id,
"queryLimit": query_limit,
"sql_editor_id": sql_editor_id,
}
if tmp_table_name:
json_payload["tmp_table_name"] = tmp_table_name
if select_as_cta:
json_payload["select_as_cta"] = select_as_cta
resp = self.get_json_resp(
"/superset/sql_json/",
raise_on_error=False,
json_=dict(
database_id=dbid,
sql=sql,
select_as_create_as=False,
client_id=client_id,
queryLimit=query_limit,
sql_editor_id=sql_editor_id,
),
"/superset/sql_json/", raise_on_error=False, json_=json_payload
)
if raise_on_error and "error" in resp:
raise Exception("run_sql failed")