-
Notifications
You must be signed in to change notification settings - Fork 17
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
add initial support for semantic_manifest files #106
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import.
The import
SemanticManifestV1
is currently unused and should be removed to address the static analysis warning.- from dbt_artifacts_parser.parsers.semantic_manifest.semantic_manifest_v1 import SemanticManifestV1
Committable suggestion
Tools
Ruff