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

[fix] Issue with previously defined SQL configuration #9082

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions superset/models/core.py
Expand Up @@ -297,24 +297,26 @@ def get_sqla_engine(
if nullpool:
params["poolclass"] = NullPool

connect_args = params.get("connect_args", {})
configuration = connect_args.get("configuration", {})

# If using Hive, this will set hive.server2.proxy.user=$effective_username
configuration: Dict[str, Any] = {}
configuration.update(
self.db_engine_spec.get_configuration_for_impersonation(
str(sqlalchemy_url), self.impersonate_user, effective_username
)
)
if configuration:
d = params.get("connect_args", {})
d["configuration"] = configuration
params["connect_args"] = d
connect_args["configuration"] = configuration
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply renamed d to the more descriptive connect_args.

params["connect_args"] = connect_args

params.update(self.get_encrypted_extra())

if DB_CONNECTION_MUTATOR:
sqlalchemy_url, params = DB_CONNECTION_MUTATOR(
sqlalchemy_url, params, effective_username, security_manager, source
)

return create_engine(sqlalchemy_url, **params)

def get_reserved_words(self) -> Set[str]:
Expand Down Expand Up @@ -598,7 +600,7 @@ def get_foreign_keys(
return self.inspector.get_foreign_keys(table_name, schema)

def get_schema_access_for_csv_upload( # pylint: disable=invalid-name
self
self,
) -> List[str]:
return self.get_extra().get("schemas_allowed_for_csv_upload", [])

Expand Down