Skip to content

Commit e2d6fb1

Browse files
Merge pull request #1129 from gooddata/snapshot-master-c131be2c-to-rel/dev
[bot] Merge master/c131be2c into rel/dev
2 parents e198eb5 + c131be2 commit e2d6fb1

File tree

16 files changed

+2323
-2414
lines changed

16 files changed

+2323
-2414
lines changed

gooddata-fdw/tests/import_foreign_schema/fixtures/import_compute_without_restrictions.yaml

Lines changed: 81 additions & 138 deletions
Large diffs are not rendered by default.

gooddata-fdw/tests/import_foreign_schema/fixtures/import_insights_without_restrictions.yaml

Lines changed: 201 additions & 277 deletions
Large diffs are not rendered by default.

gooddata-sdk/gooddata_sdk/catalog/entity.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from gooddata_sdk.catalog.base import Base, JsonApiEntityBase
1313
from gooddata_sdk.compute.model.base import ObjId
14-
from gooddata_sdk.utils import AllPagedEntities
14+
from gooddata_sdk.utils import AllPagedEntities, safeget_list
1515

1616
T = TypeVar("T", bound="AttrCatalogEntity")
1717

@@ -84,6 +84,10 @@ def from_api(
8484
def client_class() -> Any:
8585
return NotImplemented
8686

87+
def _relation_entity_from_side_loads(self, entity: builtins.type[T], path: list[str]) -> list[T]:
88+
related_fact_ids = [(x.get("id"), x.get("type")) for x in safeget_list(self.json_api_relationships, path)]
89+
return [entity.from_api(sl) for sl in self.json_api_side_loads if (sl["id"], sl["type"]) in related_fact_ids]
90+
8791

8892
class CatalogEntity:
8993
def __init__(self, entity: dict[str, Any]) -> None:

gooddata-sdk/gooddata_sdk/catalog/workspace/content_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_full_catalog(self, workspace_id: str, inject_valid_objects_func: bool =
7979
get_datasets = functools.partial(
8080
self._entities_api.get_all_entities_datasets,
8181
workspace_id,
82-
include=["attributes", "facts"],
82+
include=["attributes", "facts", "aggregatedFacts"],
8383
_check_return_type=False,
8484
)
8585

gooddata-sdk/gooddata_sdk/catalog/workspace/declarative_model/workspace/logical_model/dataset/dataset.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class CatalogDeclarativeDataset(Base):
4343
attributes: Optional[list[CatalogDeclarativeAttribute]] = None
4444
facts: Optional[list[CatalogDeclarativeFact]] = None
4545
aggregated_facts: Optional[list[CatalogDeclarativeAggregatedFact]] = attrs.field(factory=list)
46+
precedence: Optional[int] = None
4647
data_source_table_id: Optional[CatalogDataSourceTableIdentifier] = None
4748
sql: Optional[CatalogDeclarativeDatasetSql] = None
4849
tags: Optional[list[str]] = None

gooddata-sdk/gooddata_sdk/catalog/workspace/entity_model/content_objects/dataset.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ class CatalogAggregatedFact(AttrCatalogEntity):
106106
def client_class() -> Any:
107107
return JsonApiAggregatedFactOut
108108

109-
def as_computable(self) -> Metric:
110-
return SimpleMetric(local_id=self.id, item=self.obj_id)
111-
109+
# as_computable skipped because aggregated fact cannot be ever used in metric
112110
# TODO - dataset?
113111

114112

@@ -131,20 +129,22 @@ def generate_attributes_from_api(self) -> list[CatalogAttribute]:
131129
repr=False,
132130
default=attr.Factory(lambda self: self.generate_attributes_from_api(), takes_self=True),
133131
)
134-
135-
def generate_facts_from_api(self) -> list[CatalogFact]:
136-
related_fact_ids = [x.get("id") for x in safeget_list(self.json_api_relationships, ["facts", "data"])]
137-
return [
138-
CatalogFact.from_api(sl)
139-
for sl in self.json_api_side_loads
140-
if sl["type"] == "fact" and sl["id"] in related_fact_ids
141-
]
142-
143132
facts: list[CatalogFact] = attr.field(
144133
repr=False,
145-
default=attr.Factory(lambda self: self.generate_facts_from_api(), takes_self=True),
134+
default=attr.Factory(
135+
lambda self: self._relation_entity_from_side_loads(CatalogFact, ["facts", "data"]), takes_self=True
136+
),
137+
)
138+
aggregated_facts: Optional[list[CatalogAggregatedFact]] = attr.field(
139+
repr=False,
140+
default=attr.Factory(
141+
lambda self: self._relation_entity_from_side_loads(CatalogAggregatedFact, ["aggregatedFacts", "data"]),
142+
takes_self=True,
143+
),
144+
)
145+
precedence: Optional[int] = attr.field(
146+
default=attr.Factory(lambda self: self.json_api_attributes.get("precedence"), takes_self=True)
146147
)
147-
148148
grain: Optional[list] = attr.field(
149149
default=attr.Factory(lambda self: self.json_api_attributes.get("grain"), takes_self=True)
150150
)

gooddata-sdk/gooddata_sdk/catalog/workspace/model_container.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from gooddata_sdk.catalog.types import ValidObjects
88
from gooddata_sdk.catalog.workspace.entity_model.content_objects.dataset import (
9+
CatalogAggregatedFact,
910
CatalogAttribute,
1011
CatalogDataset,
1112
CatalogFact,
@@ -46,6 +47,10 @@ def datasets(self) -> list[CatalogDataset]:
4647
def facts(self) -> list[CatalogFact]:
4748
return [f for d in self._datasets for f in d.facts]
4849

50+
@property
51+
def aggregated_facts(self) -> list[CatalogAggregatedFact]:
52+
return [f for d in self._datasets for f in (d.aggregated_facts if d.aggregated_facts else [])]
53+
4954
@property
5055
def attributes(self) -> list[CatalogAttribute]:
5156
return [a for d in self._datasets for a in d.attributes]

0 commit comments

Comments
 (0)