Skip to content

Commit

Permalink
Add parsed_column_name property to `PydanticTimeSpineCustomGranularit…
Browse files Browse the repository at this point in the history
…yColumn` (#349)

This allows us to centralize this logic in one place to use everywhere
instead of rewriting it in different places.


### Checklist

- [ ] I have read [the contributing
guide](https://github.com/dbt-labs/dbt-semantic-interfaces/blob/main/CONTRIBUTING.md)
and understand what's expected of me
- [ ] I have signed the
[CLA](https://docs.getdbt.com/docs/contributor-license-agreements)
- [ ] This PR includes tests, or tests are not required/relevant for
this PR
- [ ] I have run `changie new` to [create a changelog
entry](https://github.com/dbt-labs/dbt-semantic-interfaces/blob/main/CONTRIBUTING.md#adding-a-changelog-entry)
  • Loading branch information
courtneyholcomb authored Sep 19, 2024
1 parent ff37d9f commit adcce4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dbt_semantic_interfaces/implementations/time_spine.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ def _implements_protocol(self) -> TimeSpineCustomGranularityColumn:
name: str
column_name: Optional[str] = None

@property
def parsed_column_name(self) -> str:
"""The name of the column in the time spine table that contains this custom granularity.
For convenience in writing configs, if there is no `column_name` set, we assume the `name`
is also the column name.
"""
return self.column_name or self.name


class PydanticTimeSpine(HashableBaseModel, ProtocolHint[TimeSpine]): # noqa: D101
@override
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "dbt-semantic-interfaces"
version = "0.7.1"
version = "0.7.2.dev0"
description = 'The shared semantic layer definitions that dbt-core and MetricFlow use'
readme = "README.md"
requires-python = ">=3.8"
Expand Down

0 comments on commit adcce4a

Please sign in to comment.