Skip to content

Commit 7683f23

Browse files
committed
flattenned results
1 parent 7173b0a commit 7683f23

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

definitions/output/reports/tech_report_categories.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ category_stats AS (
5858
5959
technology_stats AS (
6060
SELECT
61-
client,
62-
technology,
63-
category_obj AS categories,
64-
IF(client = 'mobile', origins.mobile, origins.desktop) AS origins
61+
category,
62+
STRUCT(
63+
ARRAY_AGG(technology IGNORE NULLS ORDER BY origins.mobile DESC) AS mobile,
64+
ARRAY_AGG(technology IGNORE NULLS ORDER BY origins.desktop DESC) AS desktop
65+
) AS technologies
6566
FROM ${ctx.ref('reports', 'tech_report_technologies')},
66-
UNNEST(ARRAY['desktop', 'mobile']) AS client
67+
UNNEST(category_obj) AS category
68+
GROUP BY category
6769
)
6870
6971
SELECT
@@ -73,18 +75,14 @@ SELECT
7375
origins,
7476
IF(
7577
client = 'mobile',
76-
ARRAY_AGG(technology IGNORE NULLS ORDER BY technology_stats.origins.mobile DESC),
77-
ARRAY_AGG(technology IGNORE NULLS ORDER BY technology_stats.origins.desktop DESC)
78+
technologies.mobile,
79+
technologies.desktop
7880
) AS technologies
7981
FROM category_stats
8082
INNER JOIN technology_stats
81-
ON category_stats.category IN UNNEST(technology_stats.categories)
83+
USING (category)
8284
INNER JOIN category_descriptions
83-
USING (category, client)
84-
GROUP BY
85-
category,
86-
description,
87-
origins
85+
USING (category)
8886
8987
UNION ALL
9088

0 commit comments

Comments
 (0)