Skip to content

Commit

Permalink
Add label attribute to protocols
Browse files Browse the repository at this point in the history
Specifically we added the attribute to the following protocols:
- Metric
- SavedQuery
- SemanticModel
- Dimension
- Entity
- Measure
  • Loading branch information
QMalcolm committed Oct 6, 2023
1 parent d21f99a commit 1c936db
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20230926-173230.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Begin supporting `label` attr on top level objects and semantic model elements
time: 2023-09-26T17:32:30.099904-07:00
custom:
Author: QMalcolm
Issue: "143"
6 changes: 6 additions & 0 deletions dbt_semantic_interfaces/protocols/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,9 @@ def time_dimension_reference(self) -> Optional[TimeDimensionReference]:
def validity_params(self) -> Optional[DimensionValidityParams]:
"""Returns the DimensionValidityParams if they exist for the dimension implementation."""
...

@property
@abstractmethod
def label(self) -> Optional[str]:
"""Returns a string representing a human readable label for the dimension."""
pass
6 changes: 6 additions & 0 deletions dbt_semantic_interfaces/protocols/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ def is_linkable_entity_type(self) -> bool:
keys reserved for SCD Type II style data sources.
"""
...

@property
@abstractmethod
def label(self) -> Optional[str]:
"""Returns a string representing a human readable label for the entity."""
pass
6 changes: 6 additions & 0 deletions dbt_semantic_interfaces/protocols/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ def agg_time_dimension(self) -> Optional[str]: # noqa: D
def reference(self) -> MeasureReference:
"""Returns a reference to this measure."""
...

@property
@abstractmethod
def label(self) -> Optional[str]:
"""Returns a string representing a human readable label for the measure."""
pass
6 changes: 6 additions & 0 deletions dbt_semantic_interfaces/protocols/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,9 @@ def input_metrics(self) -> Sequence[MetricInput]:
@abstractmethod
def metadata(self) -> Optional[Metadata]: # noqa: D
pass

@property
@abstractmethod
def label(self) -> Optional[str]:
"""Returns a string representing a human readable label for the metric."""
pass
6 changes: 6 additions & 0 deletions dbt_semantic_interfaces/protocols/saved_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ def group_bys(self) -> Sequence[str]: # noqa: D
@abstractmethod
def where(self) -> Sequence[WhereFilter]: # noqa: D
pass

@property
@abstractmethod
def label(self) -> Optional[str]:
"""Returns a string representing a human readable label for the saved query."""
pass
6 changes: 6 additions & 0 deletions dbt_semantic_interfaces/protocols/semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,11 @@ def primary_entity_reference(self) -> Optional[EntityReference]:
"""Reference object form of primary_entity."""
pass

@property
@abstractmethod
def label(self) -> Optional[str]:
"""Returns a string representing a human readable label for the semantic model."""
pass


SemanticModelT = TypeVar("SemanticModelT", bound=SemanticModel)

0 comments on commit 1c936db

Please sign in to comment.