diff --git a/dbt_semantic_interfaces/implementations/metric.py b/dbt_semantic_interfaces/implementations/metric.py index 656e09c5..0ce031b6 100644 --- a/dbt_semantic_interfaces/implementations/metric.py +++ b/dbt_semantic_interfaces/implementations/metric.py @@ -28,10 +28,10 @@ class PydanticMetricInputMeasure(PydanticCustomInputParser, HashableBaseModel): """ name: str - filter: Optional[PydanticWhereFilterIntersection] - alias: Optional[str] - join_to_timespine: bool = False - fill_nulls_with: Optional[int] = None + filter: Optional[PydanticWhereFilterIntersection] = None + alias: Optional[str] = None + time_spine_join: bool = False + null_fill_value: Optional[float] = None @classmethod def _from_yaml_value(cls, input: PydanticParseableValueType) -> PydanticMetricInputMeasure: @@ -124,7 +124,7 @@ class PydanticMetricInput(HashableBaseModel): offset_to_grain: Optional[TimeGranularity] @property - def as_reference(self) -> MetricReference: + def metric_reference(self) -> MetricReference: """Property accessor to get the MetricReference associated with this metric input.""" return MetricReference(element_name=self.name) diff --git a/dbt_semantic_interfaces/parsing/generated_json_schemas/default_explicit_schema.json b/dbt_semantic_interfaces/parsing/generated_json_schemas/default_explicit_schema.json index 7d0c3253..61bd2d5f 100644 --- a/dbt_semantic_interfaces/parsing/generated_json_schemas/default_explicit_schema.json +++ b/dbt_semantic_interfaces/parsing/generated_json_schemas/default_explicit_schema.json @@ -211,7 +211,7 @@ "expr": { "type": [ "string", - "integer", + "number", "boolean" ] }, @@ -244,17 +244,17 @@ "alias": { "type": "string" }, - "fill_nulls_with": { - "type": "integer" - }, "filter": { "$ref": "#/definitions/filter_schema" }, - "join_to_timespine": { - "type": "boolean" - }, "name": { "type": "string" + }, + "null_fill_value": { + "type": "number" + }, + "time_spine_join": { + "type": "boolean" } }, "type": "object" diff --git a/dbt_semantic_interfaces/parsing/schemas.py b/dbt_semantic_interfaces/parsing/schemas.py index 9144c2b2..89f13163 100644 --- a/dbt_semantic_interfaces/parsing/schemas.py +++ b/dbt_semantic_interfaces/parsing/schemas.py @@ -60,8 +60,8 @@ "name": {"type": "string"}, "filter": {"$ref": "filter_schema"}, "alias": {"type": "string"}, - "join_to_timespine": {"type": "boolean"}, - "fill_nulls_with": {"type": "integer"}, + "time_spine_join": {"type": "boolean"}, + "null_fill_value": {"type": "number"}, }, "additionalProperties": False, }, @@ -177,7 +177,7 @@ "type": "string", "pattern": TRANSFORM_OBJECT_NAME_PATTERN, }, - "expr": {"type": ["string", "integer", "boolean"]}, + "expr": {"type": ["string", "number", "boolean"]}, "agg_params": {"$ref": "aggregation_type_params_schema"}, "create_metric": {"type": "boolean"}, "create_metric_display_name": {"type": "string"}, diff --git a/dbt_semantic_interfaces/protocols/metric.py b/dbt_semantic_interfaces/protocols/metric.py index 31f21682..2902ae3b 100644 --- a/dbt_semantic_interfaces/protocols/metric.py +++ b/dbt_semantic_interfaces/protocols/metric.py @@ -46,13 +46,13 @@ def post_aggregation_measure_reference(self) -> MeasureReference: @property @abstractmethod - def join_to_timespine(self) -> bool: - """If the measure should be joined to the timespine.""" + def time_spine_join(self) -> bool: + """If the measure should be joined to the time spine.""" pass @property @abstractmethod - def fill_nulls_with(self) -> Optional[int]: + def null_fill_value(self) -> Optional[float]: """What null values should be filled with if set.""" pass @@ -102,7 +102,7 @@ def offset_to_grain(self) -> Optional[TimeGranularity]: # noqa: D @property @abstractmethod - def as_reference(self) -> MetricReference: + def metric_reference(self) -> MetricReference: """Property accessor to get the MetricReference associated with this metric input.""" ... diff --git a/dbt_semantic_interfaces/references.py b/dbt_semantic_interfaces/references.py index 0c92bb27..0c7dc405 100644 --- a/dbt_semantic_interfaces/references.py +++ b/dbt_semantic_interfaces/references.py @@ -12,14 +12,14 @@ class ElementReference(SerializableDataclass): element_name: str -@dataclass(frozen=True) +@dataclass(frozen=True, order=True) class LinkableElementReference(ElementReference): """Used when we need to refer to a dimension or entity, but other attributes are unknown.""" pass -@dataclass(frozen=True) +@dataclass(frozen=True, order=True) class MeasureReference(ElementReference): """Used when we need to refer to a measure. @@ -29,7 +29,7 @@ class MeasureReference(ElementReference): pass -@dataclass(frozen=True) +@dataclass(frozen=True, order=True) class DimensionReference(LinkableElementReference): # noqa: D pass @@ -38,12 +38,12 @@ def time_dimension_reference(self) -> TimeDimensionReference: # noqa: D return TimeDimensionReference(element_name=self.element_name) -@dataclass(frozen=True) +@dataclass(frozen=True, order=True) class EntityReference(LinkableElementReference): # noqa: D pass -@dataclass(frozen=True) +@dataclass(frozen=True, order=True) class TimeDimensionReference(DimensionReference): # noqa: D pass @@ -51,7 +51,7 @@ def dimension_reference(self) -> DimensionReference: # noqa: D return DimensionReference(element_name=self.element_name) -@dataclass(frozen=True) +@dataclass(frozen=True, order=True) class MetricReference(ElementReference): # noqa: D pass @@ -66,14 +66,14 @@ class ModelReference(SerializableDataclass): pass -@dataclass(frozen=True) +@dataclass(frozen=True, order=True) class SemanticModelReference(ModelReference): """A reference to a semantic model definition in the model.""" semantic_model_name: str -@dataclass(frozen=True) +@dataclass(frozen=True, order=True) class SemanticModelElementReference(ModelReference): """A reference to an element definition in a semantic model definition in the model. @@ -101,7 +101,7 @@ def is_from(self, ref: SemanticModelReference) -> bool: return self.semantic_model_name == ref.semantic_model_name -@dataclass(frozen=True) +@dataclass(frozen=True, order=True) class MetricModelReference(ModelReference): """A reference to a metric definition in the model.""" diff --git a/tests/parsing/test_metric_parsing.py b/tests/parsing/test_metric_parsing.py index dba46209..243f8472 100644 --- a/tests/parsing/test_metric_parsing.py +++ b/tests/parsing/test_metric_parsing.py @@ -55,8 +55,8 @@ def test_legacy_metric_input_measure_object_parsing() -> None: measure: name: legacy_measure_from_object filter: "{{ dimension('some_bool') }}" - join_to_timespine: true - fill_nulls_with: 1 + time_spine_join: true + null_fill_value: 1 """ ) file = YamlConfigFile(filepath="inline_for_test", contents=yaml_contents) @@ -70,8 +70,8 @@ def test_legacy_metric_input_measure_object_parsing() -> None: filter=PydanticWhereFilterIntersection( where_filters=[PydanticWhereFilter(where_sql_template="""{{ dimension('some_bool') }}""")] ), - join_to_timespine=True, - fill_nulls_with=1, + time_spine_join=True, + null_fill_value=1, )