Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 13 commits into from
Mar 3, 2020
Prev Previous commit
Next Next commit
Switch to python3 mypy
  • Loading branch information
bogdan-dbx committed Feb 26, 2020
commit 4cc14b203f3e0a723cc91bfef8985a1a4cb1503e
7 changes: 3 additions & 4 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,9 @@ class CeleryConfig: # pylint: disable=too-few-public-methods
# else:
# return f'tmp_{schema}'
# Function accepts database object, user object, schema name and sql that will be run.
SQLLAB_CTA_SCHEMA_NAME_FUNC = (
None
) # type: Optional[Callable[["Database", "models.User", str, str], str]]

SQLLAB_CTA_SCHEMA_NAME_FUNC: Optional[
Callable[["Database", "models.User", str, str], str]
] = None

# An instantiated derivative of werkzeug.contrib.cache.BaseCache
# if enabled, it can be used to store the results of long-running queries
Expand Down
6 changes: 2 additions & 4 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ def _deserialize_results_payload(
def get_cta_schema_name(
database: Database, user: ab_models.User, schema: str, sql: str
) -> Optional[str]:
func = config.get(
"SQLLAB_CTA_SCHEMA_NAME_FUNC"
) # type: Optional[Callable[[Database, ab_models.User, str, str], str]]
func: Optional[Callable[[Database, ab_models.User, str, str], str]] = config["SQLLAB_CTA_SCHEMA_NAME_FUNC"]
if not func:
return None
return func(database, user, schema, sql)
Expand Down Expand Up @@ -2349,7 +2347,7 @@ def sql_json_exec(
# Set tmp_schema_name for CTA
# TODO(bkyryliuk): consider parsing, splitting tmp_schema_name from tmp_table_name if user enters
# <schema_name>.<table_name>
tmp_schema_name = schema # type: Optional[str]
tmp_schema_name: Optional[str] = schema
if select_as_cta and mydb.force_ctas_schema:
tmp_schema_name = mydb.force_ctas_schema
elif select_as_cta:
Expand Down