Skip to content

Commit 48f183d

Browse files
committed
test: add aggregated dataset to testing ldm
risk: nonprod
1 parent 1c8cffe commit 48f183d

File tree

11 files changed

+259
-7312
lines changed

11 files changed

+259
-7312
lines changed

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
@@ -42,6 +42,7 @@ class CatalogDeclarativeDataset(Base):
4242
attributes: Optional[list[CatalogDeclarativeAttribute]] = None
4343
facts: Optional[list[CatalogDeclarativeFact]] = None
4444
aggregated_facts: Optional[list[CatalogDeclarativeAggregatedFact]] = None
45+
precedence: Optional[int] = None
4546
data_source_table_id: Optional[CatalogDataSourceTableIdentifier] = None
4647
sql: Optional[CatalogDeclarativeDatasetSql] = None
4748
tags: Optional[list[str]] = None

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ def generate_facts_from_api(self) -> list[CatalogFact]:
145145
default=attr.Factory(lambda self: self.generate_facts_from_api(), takes_self=True),
146146
)
147147

148+
# TODO: Doublecheck if we shouldn't do something like for facts
149+
aggregated_facts: Optional[list[CatalogAggregatedFact]] = attr.field(
150+
default=attr.Factory(lambda self: self.json_api_attributes.get("aggregatedFacts"), takes_self=True),
151+
)
152+
precedence: Optional[int] = attr.field(
153+
default=attr.Factory(lambda self: self.json_api_attributes.get("precedence"), takes_self=True)
154+
)
155+
148156
grain: Optional[list] = attr.field(
149157
default=attr.Factory(lambda self: self.json_api_attributes.get("grain"), takes_self=True)
150158
)

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]
53+
4954
@property
5055
def attributes(self) -> list[CatalogAttribute]:
5156
return [a for d in self._datasets for a in d.attributes]

gooddata-sdk/tests/catalog/expected/declarative_workspaces.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,6 +2376,70 @@
23762376
],
23772377
"title": "Campaign channels"
23782378
},
2379+
{
2380+
"attributes": [
2381+
{
2382+
"description": "Category Agg",
2383+
"id": "campaign_channels.category_agg",
2384+
"sourceColumn": "category",
2385+
"sourceColumnDataType": "STRING",
2386+
"labels": [],
2387+
"tags": [
2388+
"Campaign channels"
2389+
],
2390+
"title": "Category"
2391+
}
2392+
],
2393+
"description": "Campaign channels per categories",
2394+
"facts": [],
2395+
"aggregatedFacts": [
2396+
{
2397+
"description": "Budget Agg",
2398+
"id": "budget_agg",
2399+
"sourceColumn": "budget",
2400+
"sourceColumnDataType": "INT",
2401+
"tags": [
2402+
"Campaign channels per category"
2403+
],
2404+
"sourceFactReference": {
2405+
"reference": {
2406+
"id": "budget",
2407+
"type": "fact"
2408+
},
2409+
"operation": "SUM"
2410+
}
2411+
}
2412+
],
2413+
"grain": [
2414+
{
2415+
"id": "campaign_channels.category_agg",
2416+
"type": "attribute"
2417+
}
2418+
],
2419+
"id": "campaign_channels_per_category",
2420+
"precedence": 1,
2421+
"references": [
2422+
{
2423+
"identifier": {
2424+
"id": "campaign_channels",
2425+
"type": "dataset"
2426+
},
2427+
"multivalue": false,
2428+
"sourceColumns": [
2429+
"campaign_channel_category"
2430+
],
2431+
"sourceColumnDataTypes": [ "STRING" ]
2432+
}
2433+
],
2434+
"tags": [
2435+
"Campaign channels per category"
2436+
],
2437+
"sql": {
2438+
"statement": "SELECT category, SUM(budget) FROM campaign_channels GROUP BY category",
2439+
"dataSourceId": "demo-test-ds"
2440+
},
2441+
"title": "Campaign channels per category"
2442+
},
23792443
{
23802444
"attributes": [
23812445
{
@@ -2412,6 +2476,7 @@
24122476
},
24132477
"description": "Campaigns",
24142478
"facts": [],
2479+
"aggregatedFacts": [],
24152480
"grain": [
24162481
{
24172482
"id": "campaign_id",
@@ -2494,6 +2559,7 @@
24942559
},
24952560
"description": "Customers",
24962561
"facts": [],
2562+
"aggregatedFacts": [],
24972563
"grain": [
24982564
{
24992565
"id": "customer_id",
@@ -2575,6 +2641,7 @@
25752641
"title": "Quantity"
25762642
}
25772643
],
2644+
"aggregatedFacts": [],
25782645
"grain": [
25792646
{
25802647
"id": "order_line_id",
@@ -2724,6 +2791,7 @@
27242791
},
27252792
"description": "Products",
27262793
"facts": [],
2794+
"aggregatedFacts": [],
27272795
"grain": [
27282796
{
27292797
"id": "product_id",

0 commit comments

Comments
 (0)