-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add initial support for semantic_manifest files
- Loading branch information
Showing
8 changed files
with
283 additions
and
0 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
16 changes: 16 additions & 0 deletions
16
dbt_artifacts_parser/parsers/semantic_manifest/__init__.py
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,16 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# |
127 changes: 127 additions & 0 deletions
127
dbt_artifacts_parser/parsers/semantic_manifest/semantic_manifest_v1.py
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,127 @@ | ||
from typing import Dict, List, Optional | ||
|
||
from pydantic import ConfigDict | ||
from dbt_artifacts_parser.parsers.base import BaseParserModel | ||
|
||
class NodeRelation(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
alias: str | ||
schema_name: str | ||
database: str | ||
relation_name: str | ||
|
||
|
||
class Measure(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
name: str | ||
filter: Optional[str] | ||
alias: Optional[str] | ||
|
||
|
||
class TypeParams(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
measure: Measure | ||
numerator: Optional[str] = "" | ||
denominator: Optional[str] = "" | ||
expr: Optional[str] = "" | ||
window: Optional[str] = "" | ||
grain_to_date: Optional[str] = "" | ||
metrics: List[str] | ||
input_measures: List[str] | ||
|
||
|
||
class Metric(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
name: str | ||
description: str | ||
type: str | ||
type_params: TypeParams | ||
filter: Optional[str] = "" | ||
metadata: Optional[Dict[str, str]] = {} | ||
|
||
|
||
class TimeSpineTableConfiguration(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
location: str | ||
column_name: str | ||
grain: str | ||
|
||
|
||
class ProjectConfiguration(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
time_spine_table_configurations: List[TimeSpineTableConfiguration] | ||
metadata: Optional[Dict[str, str]] = {} | ||
dsi_package_version: Dict[str, str] | ||
|
||
|
||
class SavedQueryExportConfig(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
export_as: str | ||
schema_name: Optional[str] = "" | ||
alias: Optional[str] = "" | ||
|
||
|
||
class SavedQueryExport(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
name: str | ||
config: SavedQueryExportConfig | ||
|
||
|
||
class SavedQueryParams(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
metrics: List[str] | ||
group_by: List[str] | ||
where: Optional[List[str]] = [] | ||
|
||
|
||
class SavedQuery(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
name: str | ||
query_params: SavedQueryParams | ||
description: str | ||
metadata: Optional[Dict[str, str]] = {} | ||
label: Optional[str] = "" | ||
exports: List[SavedQueryExport] | ||
|
||
|
||
class SemanticModel(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
name: str | ||
defaults: Optional[Dict[str, str]] = {} | ||
description: str | ||
node_relation: NodeRelation | ||
entities: List[str] | ||
measures: List[str] | ||
dimensions: List[str] | ||
metrics: List[Metric] | ||
project_configuration: ProjectConfiguration | ||
saved_queries: List[SavedQuery] | ||
|
||
|
||
class SemanticManifestV1(BaseParserModel): | ||
model_config = ConfigDict( | ||
extra='forbid', | ||
) | ||
semantic_models: List[SemanticModel] |
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"semantic_models": [ | ||
{ | ||
"name": "semantic model name", | ||
"defaults": null, | ||
"description": "semantic model description", | ||
"node_relation": { | ||
"alias": "model alias", | ||
"schema_name": "model schema", | ||
"database": "model db", | ||
"relation_name": "Fully qualified relation name" | ||
}, | ||
"entities": ["entities in the semantic model"], | ||
"measures": ["measures in the semantic model"], | ||
"dimensions": ["dimensions in the semantic model" ], | ||
"metrics": [ | ||
{ | ||
"name": "name of the metric", | ||
"description": "metric description", | ||
"type": "metric type", | ||
"type_params": { | ||
"measure": { | ||
"name": "name for measure", | ||
"filter": "filter for measure", | ||
"alias": "alias for measure" | ||
}, | ||
"numerator": null, | ||
"denominator": null, | ||
"expr": null, | ||
"window": null, | ||
"grain_to_date": null, | ||
"metrics": ["metrics used in defining the metric. this is used in derived metrics"], | ||
"input_measures": [] | ||
}, | ||
"filter": null, | ||
"metadata": null | ||
} | ||
], | ||
"project_configuration": { | ||
"time_spine_table_configurations": [ | ||
{ | ||
"location": "fully qualified table name for timespine", | ||
"column_name": "date column", | ||
"grain": "day" | ||
} | ||
], | ||
"metadata": null, | ||
"dsi_package_version": {} | ||
}, | ||
"saved_queries": [ | ||
{ | ||
"name": "name of the saved query", | ||
"query_params": { | ||
"metrics": [ | ||
"metrics used in the saved query" | ||
], | ||
"group_by": [ | ||
"TimeDimension('model_primary_key__date_column', 'day')", | ||
"Dimension('model_primary_key__metric_one')", | ||
"Dimension('model__dimension')" | ||
], | ||
"where": null | ||
}, | ||
"description": "Description of the saved query", | ||
"metadata": null, | ||
"label": null, | ||
"exports": [ | ||
{ | ||
"name": "saved_query_name", | ||
"config": { | ||
"export_as": "view", | ||
"schema_name": null, | ||
"alias": null | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
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