Skip to content

Commit

Permalink
Convert derivation group comp to use left join to keep empty derivati…
Browse files Browse the repository at this point in the history
…on groups
  • Loading branch information
JosephVolosin committed Aug 7, 2024
1 parent 219076f commit ed6ea23
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions deployment/hasura/migrations/Aerie/10_derived_events/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ SELECT derivation_group.id,
array_agg(DISTINCT sources.type) AS event_types,
count(DISTINCT c.event_key) AS derived_total
FROM merlin.derivation_group
JOIN ( SELECT external_source.id AS source_id,
LEFT JOIN ( SELECT external_source.id AS source_id,
external_source.key,
count(a.event_key) AS contained_events,
external_event_type.name AS type,
Expand All @@ -95,7 +95,7 @@ SELECT derivation_group.id,
FROM merlin.external_event) a ON a.source_id = external_source.id
JOIN merlin.external_event_type ON external_event_type.id = a.event_type_id
GROUP BY external_source.id, external_source.key, external_source.derivation_group_id, external_source.valid_at, type) sources ON sources.derivation_group_id = derivation_group.id
JOIN ( SELECT derived_events.event_key,
LEFT JOIN ( SELECT derived_events.event_key,
derived_events.derivation_group_id
FROM merlin.derived_events) c ON c.derivation_group_id = derivation_group.id
GROUP BY derivation_group.id, derivation_group.name, derivation_group.source_type_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SELECT derivation_group.id,
array_agg(DISTINCT sources.type) AS event_types,
count(DISTINCT c.event_key) AS derived_total
FROM merlin.derivation_group
JOIN ( SELECT external_source.id AS source_id,
LEFT JOIN ( SELECT external_source.id AS source_id,
external_source.key,
count(a.event_key) AS contained_events,
external_event_type.name AS type,
Expand All @@ -20,7 +20,7 @@ SELECT derivation_group.id,
FROM merlin.external_event) a ON a.source_id = external_source.id
JOIN merlin.external_event_type ON external_event_type.id = a.event_type_id
GROUP BY external_source.id, external_source.key, external_source.derivation_group_id, external_source.valid_at, type) sources ON sources.derivation_group_id = derivation_group.id
JOIN ( SELECT derived_events.event_key,
LEFT JOIN ( SELECT derived_events.event_key,
derived_events.derivation_group_id
FROM merlin.derived_events) c ON c.derivation_group_id = derivation_group.id
GROUP BY derivation_group.id, derivation_group.name, derivation_group.source_type_id;
Expand Down

0 comments on commit ed6ea23

Please sign in to comment.