This repository has been archived by the owner on Nov 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PostgreSQL] Create DEG for schemas (#225)
* [PostgreSQL] Create DEG for schemas * Add schemas metadata * Use defaultdict --------- Co-authored-by: Mateusz Kulas <[email protected]>
- Loading branch information
Showing
5 changed files
with
76 additions
and
16 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,14 +1,17 @@ | ||
from funcy import lpluck_attr | ||
from odd_models import DataEntity, DataEntityGroup, DataEntityType | ||
from oddrn_generator import PostgresqlGenerator | ||
|
||
|
||
def map_database( | ||
generator: PostgresqlGenerator, database: str, entities: list[str] | ||
generator: PostgresqlGenerator, database: str, schema_entities: list[DataEntity] | ||
) -> DataEntity: | ||
return DataEntity( | ||
oddrn=generator.get_oddrn_by_path("databases"), | ||
name=database, | ||
type=DataEntityType.DATABASE_SERVICE, | ||
metadata=[], | ||
data_entity_group=DataEntityGroup(entities_list=entities), | ||
data_entity_group=DataEntityGroup( | ||
entities_list=lpluck_attr("oddrn", schema_entities) | ||
), | ||
) |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from funcy import lpluck_attr | ||
from odd_collector_sdk.utils.metadata import extract_metadata, DefinitionType | ||
from odd_models import DataEntity, DataEntityGroup, DataEntityType | ||
from oddrn_generator import PostgresqlGenerator | ||
|
||
from odd_collector.adapters.postgresql.models import Schema | ||
|
||
|
||
def map_schema( | ||
generator: PostgresqlGenerator, schema: Schema, table_entities: list[DataEntity] | ||
) -> DataEntity: | ||
return DataEntity( | ||
oddrn=generator.get_oddrn_by_path("schemas"), | ||
name=schema.schema_name, | ||
type=DataEntityType.DATABASE_SERVICE, | ||
metadata=[extract_metadata("postgres", schema, DefinitionType.DATASET)], | ||
data_entity_group=DataEntityGroup( | ||
entities_list=lpluck_attr("oddrn", table_entities) | ||
), | ||
) |
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