view: dt_missing_track_duration { sql_table_name: INTELLIGENCE.DBT_PROD.DT_MISSING_TRACK_DURATION ;; # derived_table: { # sql: # SELECT r.upc, t.track_id, t.cd # FROM orchard_app_reporting_v2.ART_RELATIONS_PROD_ART_RELATIONS.RELEASES r # INNER JOIN orchard_app_reporting_v2.ART_RELATIONS_PROD_ART_RELATIONS.ARTIST_INFO ai ON ai.artist_id = r.artist_id # AND r.not_for_distribution = 'N' # INNER JOIN royalty_accounting_reporting.prod.vw_dim_abacus_ar_vendor v ON v.vendor_id = ai.vendor_id # INNER JOIN orchard_app_reporting_v2.ART_RELATIONS_PROD_ART_RELATIONS.TRACK t ON t.upc = r.upc # INNER JOIN ( # orchard_app_reporting_v2.REPORTSDD_DIRECT_DELIVERY.ASSET a # INNER JOIN orchard_app_reporting_v2.REPORTSDD_DIRECT_DELIVERY.ASSET_LOCATION aloc # ON aloc.asset_id = a.asset_id # INNER JOIN orchard_app_reporting_v2.REPORTSDD_DIRECT_DELIVERY.ASSET_LOCATION_DETAIL ald # ON ald.asset_location_id = aloc.asset_location_id # INNER JOIN orchard_app_reporting_v2.REPORTSDD_DIRECT_DELIVERY.STORAGE_DRIVE sd # ON sd.storage_drive_id = aloc.storage_drive_id # INNER JOIN orchard_app_reporting_v2.REPORTSDD_DIRECT_DELIVERY.STORAGE s # ON s.storage_id = sd.storage_id AND s.physical_location_id = 1 # ) ON a.upc = r.upc # AND ald.filename = # CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(t.upc,'_'),t.cd),'_'),t.track_id),'.wav') # AND a.asset_type_id = 1 # WHERE # ( # ( # COALESCE(t.length_minute, 0) * 60 # ) + COALESCE(t.length_seconds, 0) = 0 # OR COALESCE(ald.duration, 0) = 0 # OR # ( # ABS( # ( # ( # COALESCE(t.length_minute, 0) * 60 # ) + COALESCE(t.length_seconds, 0) # ) - COALESCE(ald.duration, 0) # ) > 10 # ) # ) # AND r.release_status = 'in_content' # AND r.deletions <> 'Y' # AND v.vendor_id NOT IN (7123, 25824,16055) # AND t.track_type = 'music' # AND YEAR(r.release_date) = YEAR(CURRENT_DATE()) # GROUP BY r.upc, r.release_status, v.owner, v.vendor_id, # t.length_minute,t.length_seconds, ald.duration, t.track_id, t.cd # ORDER BY r.upc # ;; # } dimension: upc { type: string label: "UPC" sql: ${TABLE}.upc;; } dimension: track_id { type: string sql: ${TABLE}.track_id;; } dimension: cd { type: string sql: ${TABLE}.cd;; } }