Skip to content

Commit

Permalink
example rs run to sdssid load
Browse files Browse the repository at this point in the history
  • Loading branch information
johndonor3 committed Sep 11, 2024
1 parent 562b55c commit 9316fa2
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions schema/sdss5db/targetdb/load_table/metrics/created_views.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CREATE MATERIALIZED VIEW sandbox.done_to_sdssid
CREATE MATERIALIZED VIEW sandbox.rs_run_to_sdssid
AS
select at.mjd, t.catalogid, c.program, c.carton,
select assn.pk as assignment_pk, at.mjd, t.catalogid, c.program, c.carton,
i.label, i.default_lambda_eff, sdssid.sdss_id,
obs.label as observatory
obs.label as observatory, at.status as done,
f.field_id
from targetdb.assignment_status as at
join targetdb.assignment as assn on assn.pk = at.assignment_pk
join targetdb.hole as hole on hole.pk = assn.hole_pk
Expand All @@ -12,15 +13,34 @@ join targetdb.target as t on c2t.target_pk = t.pk
join targetdb.carton as c on c.pk = c2t.carton_pk
join targetdb.instrument as i on i.pk = assn.instrument_pk
join catalogdb.sdss_id_flat as sdssid on sdssid.catalogid = t.catalogid
where at.status = 1;
join targetdb.design_to_field as d2f on d2f.design_id = assn.design_id
join targetdb.field as f on f.pk = d2f.field_pk
join targetdb.version as v on v.pk = f.version_pk
where v.plan = 'eta-9';

CREATE MATERIALIZED VIEW sandbox.carton_to_sdssid
AS
select t.catalogid, c.program, c.carton,
i.label, i.default_lambda_eff, sdssid.sdss_id
from targetdb.carton_to_target as c2t
join targetdb.target as t on c2t.target_pk = t.pk
join targetdb.carton as c on c.pk = c2t.carton_pk
join targetdb.instrument as i on i.pk = c2t.instrument_pk
join catalogdb.sdss_id_flat as sdssid on sdssid.catalogid = t.catalogid
where c.version_pk >= 136;
-- CREATE MATERIALIZED VIEW sandbox.done_to_sdssid
-- AS
-- select at.mjd, t.catalogid, c.program, c.carton,
-- i.label, i.default_lambda_eff, sdssid.sdss_id,
-- obs.label as observatory
-- from targetdb.assignment_status as at
-- join targetdb.assignment as assn on assn.pk = at.assignment_pk
-- join targetdb.hole as hole on hole.pk = assn.hole_pk
-- join targetdb.observatory as obs on obs.pk = hole.observatory_pk
-- join targetdb.carton_to_target as c2t on c2t.pk = assn.carton_to_target_pk
-- join targetdb.target as t on c2t.target_pk = t.pk
-- join targetdb.carton as c on c.pk = c2t.carton_pk
-- join targetdb.instrument as i on i.pk = assn.instrument_pk
-- join catalogdb.sdss_id_flat as sdssid on sdssid.catalogid = t.catalogid
-- where at.status = 1;

-- CREATE MATERIALIZED VIEW sandbox.carton_to_sdssid
-- AS
-- select t.catalogid, c.program, c.carton,
-- i.label, i.default_lambda_eff, sdssid.sdss_id
-- from targetdb.carton_to_target as c2t
-- join targetdb.target as t on c2t.target_pk = t.pk
-- join targetdb.carton as c on c.pk = c2t.carton_pk
-- join targetdb.instrument as i on i.pk = c2t.instrument_pk
-- join catalogdb.sdss_id_flat as sdssid on sdssid.catalogid = t.catalogid
-- where c.version_pk >= 136;

0 comments on commit 9316fa2

Please sign in to comment.