Skip to content

Commit

Permalink
rm get_schema_from_engine_params from base class
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Apr 28, 2023
1 parent 61c8f27 commit 2b84d6a
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions superset/db_engine_specs/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,40 +166,6 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
),
}

@classmethod
def get_schema_from_engine_params(
cls,
sqlalchemy_uri: URL,
connect_args: Dict[str, Any],
) -> Optional[str]:
"""
Return the configured schema.
While Postgres doesn't support connecting directly to a given schema, it allows
users to specify a "search path" that is used to resolve non-qualified table
names; this can be specified in the database ``connect_args``.
One important detail is that the search path can be a comma separated list of
schemas. While this is supported by the SQLAlchemy dialect, it shouldn't be used
in Superset because it breaks schema-level permissions, since it's impossible
to determine the schema for a non-qualified table in a query. In cases like
that we raise an exception.
"""
options = re.split(r"-c\s?", connect_args.get("options", ""))
for option in options:
if "=" not in option:
continue
key, value = option.strip().split("=", 1)
if key.strip() == "search_path":
if "," in value:
raise Exception(
"Multiple schemas are configured in the search path, which means "
"Superset is unable to determine the schema of unqualified table "
"names and enforce permissions."
)
return value.strip()
return None

@classmethod
def fetch_data(
cls, cursor: Any, limit: Optional[int] = None
Expand Down

0 comments on commit 2b84d6a

Please sign in to comment.