ishmulyan commented on code in PR #36003:
URL: https://github.com/apache/superset/pull/36003#discussion_r2498265063
##########
superset/db_engine_specs/athena.py:
##########
@@ -92,3 +94,41 @@ def _mutate_label(label: str) -> str:
:return: Conditionally mutated label
"""
return label.lower()
+
+ @classmethod
+ def adjust_engine_params(
+ cls,
+ uri: URL,
+ connect_args: dict[str, Any],
+ catalog: str | None = None,
+ schema: str | None = None,
+ ) -> tuple[URL, dict[str, Any]]:
+ """
+ Adjust the SQLAlchemy URI for Athena with a provided catalog and
schema.
+
+ For AWS Athena the SQLAlchemy URI looks like this:
+
+
awsathena+rest://athena.{region_name}.amazonaws.com:443/{schema_name}?catalog_name={catalog_name}&s3_staging_dir={s3_staging_dir}
+ """
+ if catalog:
+ uri = uri.update_query_dict({"catalog_name": catalog})
+
+ if schema:
+ uri = uri.set(database=schema)
+
+ return uri, connect_args
+
+ @classmethod
+ def get_schema_from_engine_params(
+ cls,
+ sqlalchemy_uri: URL,
+ connect_args: dict[str, Any],
+ ) -> str | None:
+ """
+ Return the configured schema.
+
+ For AWS Athena the SQLAlchemy URI looks like this:
+
+
awsathena+rest://athena.{region_name}.amazonaws.com:443/{schema_name}?catalog_name={catalog_name}&s3_staging_dir={s3_staging_dir}
+ """
+ return sqlalchemy_uri.database
Review Comment:
In case `sqlalchemy_uri.database` is `None` the `None` is returned, no need
to return `None` explicitly. No additional checks or guards needed.
Presto and Snowflake checks whether database contains `/`. Because they have
different sqlalchemy connection strings and as a result a `database` could look
like `{caatalog}/{schema}`. In case `sqlalchemy_uri.database` doesn't contain
`/` it means no schemas provided and `None` is returned.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]