mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix: search_path in RDS (#24739)
(cherry picked from commit 7675e0db10)
This commit is contained in:
committed by
Michael S. Molina
parent
d87724a6e3
commit
2e222865bf
@@ -1082,22 +1082,45 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
|
||||
|
||||
For some databases (like MySQL, Presto, Snowflake) this requires modifying the
|
||||
SQLAlchemy URI before creating the connection. For others (like Postgres), it
|
||||
requires additional parameters in ``connect_args``.
|
||||
requires additional parameters in ``connect_args`` or running pre-session
|
||||
queries with ``set`` parameters.
|
||||
|
||||
When a DB engine spec implements this method it should also have the attribute
|
||||
``supports_dynamic_schema`` set to true, so that Superset knows in which schema a
|
||||
given query is running in order to enforce permissions (see #23385 and #23401).
|
||||
When a DB engine spec implements this method or ``get_prequeries`` (see below) it
|
||||
should also have the attribute ``supports_dynamic_schema`` set to true, so that
|
||||
Superset knows in which schema a given query is running in order to enforce
|
||||
permissions (see #23385 and #23401).
|
||||
|
||||
Currently, changing the catalog is not supported. The method accepts a catalog so
|
||||
that when catalog support is added to Superset the interface remains the same.
|
||||
This is important because DB engine specs can be installed from 3rd party
|
||||
packages.
|
||||
packages, so we want to keep these methods as stable as possible.
|
||||
"""
|
||||
return uri, {
|
||||
**connect_args,
|
||||
**cls.enforce_uri_query_params.get(uri.get_driver_name(), {}),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def get_prequeries(
|
||||
cls,
|
||||
catalog: str | None = None, # pylint: disable=unused-argument
|
||||
schema: str | None = None, # pylint: disable=unused-argument
|
||||
) -> list[str]:
|
||||
"""
|
||||
Return pre-session queries.
|
||||
|
||||
These are currently used as an alternative to ``adjust_engine_params`` for
|
||||
databases where the selected schema cannot be specified in the SQLAlchemy URI or
|
||||
connection arguments.
|
||||
|
||||
For example, in order to specify a default schema in RDS we need to run a query
|
||||
at the beggining of the session:
|
||||
|
||||
sql> set search_path = my_schema;
|
||||
|
||||
"""
|
||||
return []
|
||||
|
||||
@classmethod
|
||||
def patch(cls) -> None:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user