source_db: snowflake
dim_table: dim_sound_recording_artist
export_sql: >-
  SELECT
    labelid,
    subaccountid,
    isrc,
    ta.type,
    ta.name AS artistname
  FROM DIM_CANONICAL_TRACK_METADATA dctm
  LEFT JOIN ORCHARD_APP_REPORTING_V2.ART_RELATIONS_PROD_ART_RELATIONS.TRACK_ARTIST ta
    ON dctm.track_unique_id = ta.track_id
  GROUP BY 1, 2, 3, 4, 5
insert_sql:
  - >-
    TRUNCATE TABLE {db}.{schema}.{dim_table}
  - >-
    INSERT INTO
      {db}.{schema}.{dim_table}
      (
        labelid,
        subaccountid,
        isrc,
        type,
        artistname
      )
    SELECT
        st.labelid,
        st.subaccountid,
        st.isrc,
        st.type,
        st.artistname
    FROM
      {db}.{schema}.{staging_table} st
    ORDER BY
      labelid,
      subaccountid,
      isrc
insert_count_sql: >-
  SELECT count(*) FROM {db}.{schema}.{dim_table}
update_count_sql: >-
  SELECT count(*) FROM {db}.{schema}.{dim_table}
