view: cm_orchard_owned_tracks { sql_table_name: INTELLIGENCE.DBT_PROD.CM_ORCHARD_OWNED_TRACKS ;; # derived_table: { # sql: with orchard_owned_tracks as( # #with track_artists as (SELECT # tuid, # LISTAGG(DISTINCT primary_artist, ', ') WITHIN GROUP (ORDER BY primary_artist) AS primary_artists # FROM ( # SELECT # track_id AS tuid, # CASE type WHEN 'performer' THEN name ELSE NULL END AS primary_artist # FROM orchard_app_reporting_v2.art_relations_prod_art_relations.track_artist # WHERE type IN ('performer') # ) # GROUP BY 1) # #select i.isrc, r.releaseid #from facts.prod.dim_release r #left join orchard_app_reporting_v2.art_relations_prod_art_relations.RELEASES rr on rr.upc = r.releaseid #left join orchard_app_reporting_v2.art_relations_prod_art_relations.distribution_format df on df.distribution_format_id = rr.distribution_format_id #left join FACTS.PROD.DIM_ISRC i on i.upc = r.releaseid #left join FACTS.PROD.DIM_ARTIST a on r.artistid = a.artistid #left join track_artists ta on ta.tuid = i.track_id_uniq #where r.compilation = 'N' #and r.not_for_distribution = 'N' #and r.release_status = 'in_content' #and r.deletions = 'N' #and a.artistname not like INITCAP('%various%') and a.artistname not like INITCAP('%vĂ¡rios%') #and contains(lower(ta.primary_artists), lower(a.artistname)) #and df.context_type != 'physical') # #Select distinct(isrc), releaseid from orchard_owned_tracks ;; # } dimension: isrc { type: string sql: ${TABLE}.isrc ;; } dimension: releaseid { type: string sql: ${TABLE}.releaseid ;; } dimension: isorchard { label: "Is Orchard?" type: string case: { when: { sql: ${TABLE}.isrc is not null;; label: "Yes" } else: "No"} } }