view: orch_app_ar_artist_info {
  sql_table_name: orchard_app_reporting_v2.art_relations_prod_art_relations.artist_info ;;

  dimension: artist_id {
    description: "Unique identifier for each artist"
    type: number
    sql: ${TABLE}.artist_id ;;
    primary_key: yes
  }

  dimension: name {
    label: "Artist Name"
    description: "Name of the primary artist"
    type: string
    case_sensitive: yes
    sql: ${TABLE}.name ;;
    link: {
      label: "Artist View"
      url:
      "

      {% if _explore._name == 'facts_prod_fact_analytics_v2' and orch_app_ar_artist_info.name._in_query and facts_prod_fact_analytics_v2.labelid._in_query %}
      https://theorchard.looker.com/dashboards-next/1743?Artist%20Name={{ orch_app_ar_artist_info.name._value }}&Label%20ID={{ facts_prod_fact_analytics_v2.labelid._value }}


      {% else %}

      {% endif %}
      "
    }
  }

  dimension: artist_name_ascii{
    description: "This only shows names for artists which do not have any Non ASCII Characters. This field is specifically used for a Millward Brown reporting usecase"
    type: string
    label: "Artist Name (ASCII Characters): Do Not Use"
    sql: case when regexp_instr(${TABLE}.name,'[^[:ascii:]]') = 0 then ${TABLE}.name end;;
  }

  dimension: orchard_country {
    type: number
    sql: ${TABLE}.orchard_country ;;
    hidden: yes
  }

  dimension: vendor_id {
    type: number
    sql: ${TABLE}.vendor_id ;;
    hidden: yes
  }

  measure: count_artists {
    label: "Number of Artists"
    hidden: yes
    type: count_distinct
    sql: ${artist_id} ;;
  }

  # artist_key is specific to the artist_similarity model
  dimension: artist_key {
    type: string
    sql: TRIM(LOWER(${name})) ;;
    hidden: yes
  }

  ## This field is no longer updated in underlying table
  ## dimension: active {
  ##   description: "Is the artist active as per OA (Y/N)"
  ##   type: yesno
  ##   sql: IFF(${TABLE}.active = 'Y', TRUE, FALSE) ;;
  ## }

  dimension: myspace_url {
    type: string
    sql: ${TABLE}.myspace_url ;;
    hidden: yes
  }
#
#   dimension: address_city {
#     type: string
#     sql: ${TABLE}.address_city ;;
#   }
#
#   dimension: address_other_state {
#     type: string
#     sql: ${TABLE}.address_other_state ;;
#   }
#
#   dimension: address_state {
#     type: number
#     sql: ${TABLE}.address_state ;;
#   }
#
#   dimension: address_zip {
#     type: string
#     sql: ${TABLE}.address_zip ;;
#   }
#
#   dimension: artist_email {
#     type: string
#     sql: ${TABLE}.artist_email ;;
#   }
#
#   dimension: artist_type {
#     type: string
#     sql: ${TABLE}.artist_type ;;
#   }
#
#   dimension: description {
#     type: string
#     sql: ${TABLE}.description ;;
#   }
#
#   dimension: entered_by {
#     type: string
#     sql: ${TABLE}.entered_by ;;
#   }
#
#   dimension: isni_id {
#     type: string
#     sql: ${TABLE}.isni_id ;;
#   }
#
#   dimension: join_artist_id {
#     type: number
#     sql: ${TABLE}.join_artist_id ;;
#   }
#
#   dimension: last_updated {
#     type: date_time
#     sql: ${TABLE}.last_updated ;;
#   }
#
#   dimension: myspace_id {
#     type: number
#     sql: ${TABLE}.myspace_id ;;
#   }
#
#   dimension: myspace_url {
#     type: string
#     sql: ${TABLE}.myspace_url ;;
#   }
#
#   dimension: primary_photo_id {
#     type: number
#     sql: ${TABLE}.primary_photo_id ;;
#   }
#
#   dimension: rai_id {
#     type: number
#     sql: ${TABLE}.rai_id ;;
#   }
#
#   dimension: tms_id {
#     type: string
#     sql: ${TABLE}.tms_id ;;
#   }
#
#   dimension: twitter_mytourdate_url {
#     type: string
#     sql: ${TABLE}.twitter_mytourdate_url ;;
#   }
#
#   dimension: unique_artist_id {
#     type: number
#     sql: ${TABLE}.unique_artist_id ;;
#   }
#
#   dimension: unique_show_id {
#     type: string
#     sql: ${TABLE}.unique_show_id ;;
#   }
#
#   dimension: url {
#     type: string
#     sql: ${TABLE}.url ;;
#   }
#
#   dimension: when_entered {
#     type: date_time
#     sql: ${TABLE}.when_entered ;;
#   }
#
#   dimension: youtube_mytourdate_url {
#     type: string
#     sql: ${TABLE}.youtube_mytourdate_url ;;
#   }
}
