-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sc-25976] Add
database_defaults
to Metabase crawler config (#846)
- Loading branch information
1 parent
06264e8
commit 7b0bd80
Showing
7 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
from dataclasses import field | ||
from typing import List, Optional | ||
|
||
from pydantic.dataclasses import dataclass | ||
|
||
from metaphor.common.base_config import BaseConfig | ||
from metaphor.common.dataclass import ConnectorConfig | ||
|
||
|
||
@dataclass | ||
class MetabaseDatabaseDefaults: | ||
id: int | ||
default_schema: Optional[str] = None | ||
|
||
|
||
@dataclass(config=ConnectorConfig) | ||
class MetabaseRunConfig(BaseConfig): | ||
server_url: str | ||
username: str | ||
password: str | ||
|
||
database_defaults: List[MetabaseDatabaseDefaults] = field(default_factory=list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "metaphor-connectors" | ||
version = "0.13.181" | ||
version = "0.13.182" | ||
license = "Apache-2.0" | ||
description = "A collection of Python-based 'connectors' that extract metadata from various sources to ingest into the Metaphor app." | ||
authors = ["Metaphor <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,37 @@ async def test_extractor( | |
events = [EventUtil.trim_event(e) for e in await extractor.extract()] | ||
|
||
assert events == load_json(f"{test_root_dir}/metabase/expected.json") | ||
|
||
|
||
def test_parse_database(test_root_dir: str): | ||
config = MetabaseRunConfig.from_yaml_file(f"{test_root_dir}/metabase/config.yml") | ||
extractor = MetabaseExtractor(config) | ||
bq_database = { | ||
"details": { | ||
"project-id": "bq_db", | ||
}, | ||
"id": 1, | ||
"engine": "bigquery-cloud-sdk", | ||
} | ||
|
||
redshift_database = { | ||
"details": { | ||
"db": "redshift_db", | ||
}, | ||
"id": 2, | ||
"engine": "redshift", | ||
} | ||
|
||
snowflake_database = { | ||
"details": {"db": "snowflake_db", "account": "[email protected]"}, | ||
"id": 3, | ||
"engine": "snowflake", | ||
} | ||
|
||
for database in [bq_database, redshift_database, snowflake_database]: | ||
extractor._parse_database(database) | ||
|
||
assert len(extractor._databases) == 3 | ||
assert extractor._databases[1].schema == "SCH" | ||
assert extractor._databases[2].schema == "SCH2" | ||
assert not extractor._databases[3].schema |