Skip to content

Commit

Permalink
Merge pull request #376 from jaceksan/gartner
Browse files Browse the repository at this point in the history
TRIVIAL: gooddata-dbt - allow to override LDM ID

Reviewed-by: Jan Kadlec
             https://github.com/hkad98
  • Loading branch information
gdgate authored Oct 5, 2023
2 parents b48281d + a7a42ae commit 9456201
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions gooddata-dbt/gooddata_dbt/dbt/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DbtModelMetaGoodDataTableProps(Base):

@attrs.define(auto_attribs=True, kw_only=True)
class DbtModelMetaGoodDataColumnProps(Base):
id: Optional[str] = None
ldm_type: Optional[str] = None
referenced_table: Optional[str] = None
label_type: Optional[str] = None
Expand Down Expand Up @@ -115,6 +116,12 @@ class DbtModelColumn(DbtModelBase):
data_type: Optional[str]
meta: DbtModelMetaGoodDataColumn = attrs.field(factory=DbtModelMetaGoodDataColumn)

# Enable to override LDM ID for LDM entities derived from columns (attributes, ...)
# TODO - does it work for PK/references in combination with roles?
@property
def ldm_id(self) -> str:
return self.meta.gooddata.id or self.gooddata_ldm_id

def gooddata_is_fact(self) -> bool:
return (self.meta.gooddata.ldm_type == GoodDataLdmTypes.FACT.value) or self.is_number()

Expand Down Expand Up @@ -355,7 +362,7 @@ def make_facts(table: DbtModelTable) -> List[Dict]:
if column.gooddata_is_fact():
facts.append(
{
"id": column.gooddata_ldm_id,
"id": column.ldm_id,
# TODO - all titles filled from dbt descriptions, incorrect! No title in dbt models.
"title": column.gooddata_ldm_title,
"description": column.gooddata_ldm_description,
Expand All @@ -372,7 +379,7 @@ def make_labels(table: DbtModelTable, attribute_column: DbtModelColumn) -> List[
if column.gooddata_is_label(attribute_column.name):
labels.append(
{
"id": column.gooddata_ldm_id,
"id": column.ldm_id,
"title": column.gooddata_ldm_title,
"description": column.gooddata_ldm_description,
"source_column": column.name,
Expand All @@ -389,7 +396,7 @@ def make_attributes(self, table: DbtModelTable) -> List[Dict]:
if column.gooddata_is_attribute():
attributes.append(
{
"id": column.gooddata_ldm_id,
"id": column.ldm_id,
"title": column.gooddata_ldm_title,
"description": column.gooddata_ldm_description,
"source_column": column.name,
Expand All @@ -410,7 +417,7 @@ def make_date_datasets(self, table: DbtModelTable, existing_date_datasets: List[
granularities = DATE_GRANULARITIES
date_datasets.append(
{
"id": column.gooddata_ldm_id,
"id": column.ldm_id,
"title": self.get_ldm_title(column),
"description": column.description,
"tags": [table.gooddata_ldm_title] + column.tags,
Expand Down

0 comments on commit 9456201

Please sign in to comment.