From d84e84db74c1682ae643dd12d6dc5d5a28831feb Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Thu, 19 Sep 2024 09:51:39 -0700 Subject: [PATCH 1/2] Add parsed_column_name property to PydanticTimeSpineCustomGranularityColumn This allows us to centralize this logic in one place to use everywhere instead of rewriting it in different places. --- dbt_semantic_interfaces/implementations/time_spine.py | 4 ++++ pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dbt_semantic_interfaces/implementations/time_spine.py b/dbt_semantic_interfaces/implementations/time_spine.py index b010d3d2..47853900 100644 --- a/dbt_semantic_interfaces/implementations/time_spine.py +++ b/dbt_semantic_interfaces/implementations/time_spine.py @@ -35,6 +35,10 @@ def _implements_protocol(self) -> TimeSpineCustomGranularityColumn: name: str column_name: Optional[str] = None + @property + def parsed_column_name(self) -> str: + 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" From 6b2c589577a5e5d8378efeb865393d3b00257632 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Thu, 19 Sep 2024 10:23:10 -0700 Subject: [PATCH 2/2] Docstring --- dbt_semantic_interfaces/implementations/time_spine.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbt_semantic_interfaces/implementations/time_spine.py b/dbt_semantic_interfaces/implementations/time_spine.py index 47853900..7d666d0f 100644 --- a/dbt_semantic_interfaces/implementations/time_spine.py +++ b/dbt_semantic_interfaces/implementations/time_spine.py @@ -37,6 +37,11 @@ def _implements_protocol(self) -> TimeSpineCustomGranularityColumn: @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