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

Create protocol abstraction for SemanticModel #17

Closed
Tracked by #7
QMalcolm opened this issue Apr 27, 2023 · 1 comment · Fixed by #39
Closed
Tracked by #7

Create protocol abstraction for SemanticModel #17

QMalcolm opened this issue Apr 27, 2023 · 1 comment · Fixed by #39
Assignees
Labels

Comments

@QMalcolm
Copy link
Collaborator

We want a standard definition of what a valid SemanticModel implementation should have. This allows for a shared definition to be understood in MetricFlow and dbt-core of what anything implementing the SemanticModel protocol will make available without MetricFlow and dbt-core needing to import each other. This should use the new Protocol type which exists in python 3.8+

@WilliamDee
Copy link
Contributor

from __future__ import annotations

from typing import Optional, Protocol, Sequence

from dbt_semantic_interfaces.protocols.dimension import Dimension
from dbt_semantic_interfaces.protocols.entity import Entity
from dbt_semantic_interfaces.protocols.measure import Measure
from dbt_semantic_interfaces.protocols.metadata import Metadata

class NodeRelation(Protocol):
    """Path object to where the data should be"""

    alias: str
    schema_name: str
    database: Optional[str]
    relation_name: str

class SemanticModel(Protocol):
    """Describes a semantic model"""

    name: str
    description: Optional[str]
    node_relation: NodeRelation

    entities: Sequence[Entity]
    measures: Sequence[Measure]
    dimensions: Sequence[Dimension]

    metadata: Optional[Metadata]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants