eschutho commented on code in PR #44280:
URL: https://github.com/apache/superset/pull/44280#discussion_r4261212276
##########
superset/db_engine_specs/athena.py:
##########
@@ -190,3 +258,97 @@ def get_schema_from_engine_params(
awsathena+rest://athena.{region_name}.amazonaws.com:443/{schema_name}?catalog_name={catalog_name}&s3_staging_dir={s3_staging_dir}
"""
return sqlalchemy_uri.database
+
+ @classmethod
+ def build_sqlalchemy_uri(
+ cls,
+ parameters: AthenaParametersType,
+ encrypted_extra: Optional[ # pylint: disable=unused-argument
+ dict[str, Any]
+ ] = None,
+ ) -> str:
+ query: dict[str, str] = {"s3_staging_dir":
parameters["s3_staging_dir"]}
+ if work_group := parameters.get("work_group"):
+ query["work_group"] = work_group
+
+ # SQLAlchemy 2.0 made URL.__str__() hide the password by default
+ # (it rendered in full under 1.4); render_as_string(hide_password=
+ # False) is required here since this URI is stored/used to actually
+ # connect, not just displayed.
+ return URL.create(
+ f"{cls.engine}+{cls.default_driver}",
+ username=parameters.get("aws_access_key_id"),
+ password=parameters.get("aws_secret_access_key"),
+ host=f"athena.{parameters['region_name']}.amazonaws.com",
Review Comment:
Fixed in d60365e428. `ATHENA_HOST_REGEX` mirrors the pattern PyAthena itself
uses to derive the region (`athena.<region>.amazonaws.com`, also
`.amazonaws.com.cn`). Any other host, such as a VPC/PrivateLink endpoint, is
kept verbatim in `region_name`, **including its port**, and
`build_sqlalchemy_uri` uses a value containing a `.` or `:` as the host as-is
(AWS region codes never contain either) instead of re-prefixing it. China
regions rebuild to `.amazonaws.com.cn`. For standard regional hosts the port is
still dropped, since PyAthena ignores it. Covered by the parametrized
`test_parameters_round_trip_preserves_host` (PrivateLink with/without `:443`,
China partition).
--
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]