From adcce4a19c91d1357e6d9c5e90a57c6f76e7a065 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Thu, 19 Sep 2024 10:27:26 -0700 Subject: [PATCH] Add parsed_column_name property to `PydanticTimeSpineCustomGranularityColumn` (#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) --- dbt_semantic_interfaces/implementations/time_spine.py | 9 +++++++++ pyproject.toml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dbt_semantic_interfaces/implementations/time_spine.py b/dbt_semantic_interfaces/implementations/time_spine.py index b010d3d2..7d666d0f 100644 --- a/dbt_semantic_interfaces/implementations/time_spine.py +++ b/dbt_semantic_interfaces/implementations/time_spine.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 70038144..c7daf956 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"