You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "ishmulyan (via GitHub)" <gi...@apache.org> on 2025/11/05 13:52:47 UTC
[PR] feat(db): add dynamic schema support for athena [superset]
ishmulyan opened a new pull request, #36003:
URL: https://github.com/apache/superset/pull/36003
### SUMMARY
This PR adds dynamic schema support to AWS Athena connection.
When Athena connection is configured to some schema selecting different schema in SQL Lab or Dataset configuration doesn't affect the query.
As a result it ends up looking for the table in the connection configured schema (not in selected) and fails with table not found error.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
<img width="2230" height="1492" alt="Screenshot From 2025-11-05 15-42-28" src="https://github.com/user-attachments/assets/ff8b2b45-6a3d-4515-80e2-f42f02f97134" />
After:
<img width="2230" height="1492" alt="Screenshot From 2025-11-05 15-42-43" src="https://github.com/user-attachments/assets/1d461303-dfa1-45c6-bdcb-0dcf3f810023" />
### TESTING INSTRUCTIONS
Unit tests added.
To manually test:
- Install PyAthena module and connect to AWS Athena.
- Check you're able to run a SQL query without specifying the schema in the SQL statement as long as it's selected in the dropdown.
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "ishmulyan (via GitHub)" <gi...@apache.org>.
ishmulyan commented on code in PR #36003:
URL: https://github.com/apache/superset/pull/36003#discussion_r2495213454
##########
superset/db_engine_specs/athena.py:
##########
@@ -92,3 +94,39 @@ 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 schema.
+
+ For AWS Athena the SQLAlchemy URI looks like this:
+
+ awsathena+rest://{aws_access_key_id}:{aws_secret_access_key}@athena.{region_name}.amazonaws.com:443/{schema_name}?s3_staging_dir={s3_staging_dir}&...
+ """
+ if not schema:
+ return uri, connect_args
+
+ uri = uri.set(database=schema)
+ return uri, connect_args
Review Comment:
I have updated the PR with the updated code
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #36003:
URL: https://github.com/apache/superset/pull/36003#issuecomment-3492741858
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/36003?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `50.00000%` with `6 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 48.48%. Comparing base ([`04231c8`](https://app.codecov.io/gh/apache/superset/commit/04231c86dbe0ebafd87acd712b8a85b1ff5e8d1c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`6848dd4`](https://app.codecov.io/gh/apache/superset/commit/6848dd4e05826830c3b104d9a69b29f1193407b0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 4 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/36003?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/db\_engine\_specs/athena.py](https://app.codecov.io/gh/apache/superset/pull/36003?src=pr&el=tree&filepath=superset%2Fdb_engine_specs%2Fathena.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2F0aGVuYS5weQ==) | 50.00% | [6 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/36003?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #36003 +/- ##
===========================================
+ Coverage 0 48.48% +48.48%
===========================================
Files 0 622 +622
Lines 0 45730 +45730
Branches 0 4977 +4977
===========================================
+ Hits 0 22171 +22171
- Misses 0 22934 +22934
- Partials 0 625 +625
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/36003/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Ξ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/36003/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `44.20% <50.00%> (?)` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/36003/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `47.76% <50.00%> (?)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/36003/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `48.47% <50.00%> (?)` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/36003/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ΓΈ> (?)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/36003?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #36003:
URL: https://github.com/apache/superset/pull/36003
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #36003:
URL: https://github.com/apache/superset/pull/36003#discussion_r2495195272
##########
superset/db_engine_specs/athena.py:
##########
@@ -92,3 +94,39 @@ 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 schema.
+
+ For AWS Athena the SQLAlchemy URI looks like this:
+
+ awsathena+rest://{aws_access_key_id}:{aws_secret_access_key}@athena.{region_name}.amazonaws.com:443/{schema_name}?s3_staging_dir={s3_staging_dir}&...
+ """
+ if not schema:
+ return uri, connect_args
+
+ uri = uri.set(database=schema)
+ return uri, connect_args
Review Comment:
Thank you for addressing the catalog parameter. Could you share the updated code for review?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #36003:
URL: https://github.com/apache/superset/pull/36003#discussion_r2494617593
##########
superset/db_engine_specs/athena.py:
##########
@@ -92,3 +94,39 @@ 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 schema.
+
+ For AWS Athena the SQLAlchemy URI looks like this:
+
+ awsathena+rest://{aws_access_key_id}:{aws_secret_access_key}@athena.{region_name}.amazonaws.com:443/{schema_name}?s3_staging_dir={s3_staging_dir}&...
+ """
+ if not schema:
+ return uri, connect_args
+
+ uri = uri.set(database=schema)
+ return uri, connect_args
Review Comment:
### Catalog parameter ignored in URI adjustment <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The adjust_engine_params method accepts a catalog parameter but completely ignores it, only using the schema parameter to set the database field in the URI.
###### Why this matters
AWS Athena supports both catalog and schema concepts, where catalog represents the data catalog (like AWS Glue) and schema represents the database within that catalog. Ignoring the catalog parameter means the method cannot properly handle multi-catalog scenarios, potentially connecting to the wrong data source.
###### Suggested change β *Feature Preview*
Modify the method to handle both catalog and schema parameters appropriately. For Athena, if both are provided, they should be combined or the catalog should be handled through connect_args:
```python
@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 schema and catalog.
"""
if catalog:
connect_args = connect_args.copy()
connect_args['catalog_name'] = catalog
if schema:
uri = uri.set(database=schema)
return uri, connect_args
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/44c5bf79-9651-48ed-b4a6-9431f25edad2/upvote) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/44c5bf79-9651-48ed-b4a6-9431f25edad2?what_not_true=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/44c5bf79-9651-48ed-b4a6-9431f25edad2?what_out_of_scope=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/44c5bf79-9651-48ed-b4a6-9431f25edad2?what_not_in_standard=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/44c5bf79-9651-48ed-b4a6-9431f25edad2)
</details>
<sub>
π¬ Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:09b19ecd-957c-4efa-a947-4d4df1ef6a17 -->
[](09b19ecd-957c-4efa-a947-4d4df1ef6a17)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "ishmulyan (via GitHub)" <gi...@apache.org>.
ishmulyan commented on code in PR #36003:
URL: https://github.com/apache/superset/pull/36003#discussion_r2495194038
##########
superset/db_engine_specs/athena.py:
##########
@@ -92,3 +94,39 @@ 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 schema.
+
+ For AWS Athena the SQLAlchemy URI looks like this:
+
+ awsathena+rest://{aws_access_key_id}:{aws_secret_access_key}@athena.{region_name}.amazonaws.com:443/{schema_name}?s3_staging_dir={s3_staging_dir}&...
+ """
+ if not schema:
+ return uri, connect_args
+
+ uri = uri.set(database=schema)
+ return uri, connect_args
Review Comment:
updated the function to consider catalog parameter
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #36003:
URL: https://github.com/apache/superset/pull/36003#discussion_r2495666971
##########
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:
Consider adding explicit handling for empty strings to match the pattern used in similar implementations. The current code returns the database attribute directly, but if the database is an empty string, it should return `None` instead. Add: `return sqlalchemy_uri.database or None` to ensure consistent behavior.
```suggestion
return sqlalchemy_uri.database or None
```
##########
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:
The `get_schema_from_engine_params` method should handle the case where `sqlalchemy_uri.database` is `None` or an empty string. Without this check, accessing `.database` on a URL without a database component could lead to issues. Consider adding a guard to return `None` if `database` is falsy, similar to how Presto and Snowflake handle this (they check `if \"/\" not in database`).
```suggestion
database = sqlalchemy_uri.database
if not database:
return None
return database
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #36003:
URL: https://github.com/apache/superset/pull/36003#issuecomment-3491341424
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "ishmulyan (via GitHub)" <gi...@apache.org>.
ishmulyan commented on code in PR #36003:
URL: https://github.com/apache/superset/pull/36003#discussion_r2498276935
##########
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:
I do not see the same pattern over the codebase and don't think it's needed. Could you point me out to the code?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "ishmulyan (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(db): add dynamic schema support for athena [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #36003:
URL: https://github.com/apache/superset/pull/36003#issuecomment-3544194248
CC @betodealmeida
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org