Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metabase): allow configuring how database engines get mapped to platforms #3869

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion metadata-ingestion/source_docs/metabase.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,18 @@ sink:
| `username` | ✅ | | Metabase username. |
| `password` | ✅ | | Metabase password. |
| `database_alias_map` | | | Database name map to use when constructing dataset URN. |
| `engine_platform_map`| | | Custom mappings between metabase database engines and DataHub platforms |
| `default_schema` | | `public` | Default schema name to use when schema is not provided in an SQL query |
| `env` | | `"PROD"` | Environment to use in namespace when constructing URNs. |


Metabase databases will be mapped to a DataHub platform based on the engine listed in the
[api/database](https://www.metabase.com/docs/latest/api-documentation.html#database) response. This mapping can be
customized by using the `engine_platform_map` config option. For example, to map databases using the `athena` engine to
the underlying datasets in the `glue` platform, the following snippet can be used:
```yml
engine_platform_map:
athena: glue
```
DataHub will try to determine database name from Metabase [api/database](https://www.metabase.com/docs/latest/api-documentation.html#database)
payload. However, the name can be overridden from `database_alias_map` for a given database connected to Metabase.

Expand Down
5 changes: 5 additions & 0 deletions metadata-ingestion/src/datahub/ingestion/source/metabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MetabaseConfig(ConfigModel):
username: Optional[str] = None
password: Optional[str] = None
database_alias_map: Optional[dict] = None
engine_platform_map: Optional[dict] = None
default_schema: str = "public"
env: str = builder.DEFAULT_ENV

Expand Down Expand Up @@ -477,6 +478,10 @@ def get_datasource_from_id(self, datasource_id):
"sqlserver": "mssql",
"bigquery-cloud-sdk": "bigquery",
}

if self.config.engine_platform_map is not None:
engine_mapping.update(self.config.engine_platform_map)

if engine in engine_mapping:
platform = engine_mapping[engine]
else:
Expand Down