# View: cm_unioned_playlist_current

**View Name:** cm_unioned_playlist_current
**Table Source:** `intelligence.dbt_prod.cm_unioned_playlist_current`
**File Path:** `cm_unioned_playlist_current.view.lkml`

## Overview

- **File Size:** 5633 bytes
- **Lines of Code:** 165
- **Dimensions:** 12
- **Measures:** 1
- **Dimension Groups:** 1
- **Filters:** 0

## Comments & Notes

- derived_table: {
- sql:with current_playlisting as (
- #select cast(spotify as varchar) as "TRACK_ID", cast(spotify_playlist as varchar) as "PLAYLIST_ID", s.isrc as "ISRC",

## Dimensions

| Name | Type |
|------|------|
| `track_id` | string |
| `playlist_id` | string |
| `playlist_name` | string |
| `playlist_curator` | string |
| `playlist_uri` | string |
| `playlist_uri_normalized` | string |
| `playlist_url` | string |
| `store` | string |
| `country` | string |
| `geography` | string |
| `isrc` | string |
| `Editorial` | string |

## Measures

| Name | Type |
|------|------|
| `current_position` | min |

## Dimension Groups

| Name | Type |
|------|------|
| `added` | time |

## Derived Table

```sql
#    sql:with current_playlisting as (
#
#select cast(spotify as varchar) as "TRACK_ID", cast(spotify_playlist as varchar) as "PLAYLIST_ID", s.isrc as "ISRC",
#sp.name as "PLAYLIST_NAME", sp.user_id as "PLAYLIST_CURATOR", (position_latest+1) as "CURRENT_POSITION", 'Spotify' as "STORE",
#ifnull(sp.code2, 'GLOBAL') as "COUNTRY", least(ps.added_at, ps.start_sys_period) as "DATE_ADDED", sp.playlist_id as "PLAYLIST_URI", 'https://open.spotify.com/playlist/'||sp.playlist_id as "PLAYLIST_URL"
#from CHARTMETRIC.RAW_DATA.L_SPOTIFY_PLAYLIST ps
#left join CHARTMETRIC.RAW_DATA.SPOTIFY s on s.id = ps.spotify
#left join CHARTMETRIC.RAW_DATA.SPOTIFY_PLAYLIST sp on sp.id = ps.spotify_playlist
#
#union all
#
#select amazon as "TRACK_ID", amazon_playlist as "PLAYLIST_ID", a.isrc as "ISRC",
#ap.name as "PLAYLIST_NAME", ap.curator_name as "PLAYLIST_CURATOR", position as "CURRENT_POSITION", 'Amazon Music' as "STORE",
#ap.code2 as "COUNTRY", ps.start_sys_period as "DATE_ADDED", ap.id as "PLAYLIST_URI", 'https://music.amazon.com/playlists/'||ap.id as "PLAYLIST_URL"
#from CHARTMETRIC.RAW_DATA.L_AMAZON_PLAYLIST ps
#left join CHARTMETRIC.RAW_DATA.AMAZON a on a.id = ps.amazon
#left join CHARTMETRIC.RAW_DATA.AMAZON_PLAYLIST ap on ap.id = ps.amazon_playlist
#where ap.original = 'TRUE'
#
#union all
#
#Select cast(itunes as varchar) as "TRACK_ID", cast(ps.itunes_playlist as varchar) as "PLAYLIST_ID", i.isrc as "ISRC",
#ip.name as "PLAYLIST_NAME", ip.owner_name as "PLAYLIST_CURATOR", position as "CURRENT_POSITION", 'Apple Music' as "STORE",
#upper(ips.storefront) as "COUNTRY", ps.start_sys_period as "DATE_ADDED", ip.playlist_id as "PLAYLIST_URI", 'https://music.apple.com/'||lower(ps.storefront)||'/playlist/new-music-daily/'||playlist_id as "PLAYLIST_URL"
#from CHARTMETRIC.RAW_DATA.L_ITUNES_PLAYLIST ps
#left join CHARTMETRIC.RAW_DATA.ITUNES i on i.id = ps.itunes
#left join CHARTMETRIC.RAW_DATA.ITUNES_PLAYLIST ip on ip.id = ps.itunes_playlist
#left join CHARTMETRIC.RAW_DATA.ITUNES_PLAYLIST_STOREFRONT ips on ips.itunes_playlist = ip.id
#
#union all
#
#Select cast(deezer as varchar) as "TRACK_ID", cast(deezer_playlist as varchar) as "PLAYLIST_ID", d.isrc as "ISRC",
#dp.name as "PLAYLIST_NAME", '' as "PLAYLIST_CURATOR", position as "CURRENTPOSITION", 'Deezer' as "STORE",
#'' as "COUNTRY", ps.start_sys_period as "DATE_ADDED", cast(dp.id as varchar) as "PLAYLIST_URI", 'https://www.deezer.com/playlist/'||dp.id as "PLAYLIST_URL"
#from CHARTMETRIC.RAW_DATA.L_DEEZER_PLAYLIST ps
#left join CHARTMETRIC.RAW_DATA.DEEZER d on d.id = ps.deezer
#left join CHARTMETRIC.RAW_DATA.DEEZER_PLAYLIST dp on dp.id = ps.deezer_playlist
#
#union all
#
#Select  video_id as "TRACK_ID", playlist_id as "PLAYLIST_ID", y.isrc as "ISRC",
#yp.name as "PLAYLIST_NAME", '' as "PLAYLIST_CURATOR", (position+1) as "CURRENT_POSITION", 'YouTube' as "STORE",
#'' as "COUNTRY", ps.start_sys_period as "DATE_ADDED", yp.id as "PLAYLIST_URI", 'https://www.youtube.com/playlist?list='||yp.id as "PLAYLIST_URL"
#from CHARTMETRIC.RAW_DATA.L_YOUTUBE_PLAYLIST ps
#left join CHARTMETRIC.RAW_DATA.YOUTUBE y on y.id = ps.video_id
#left join CHARTMETRIC.RAW_DATA.YOUTUBE_PLAYLIST yp on yp.id = ps.playlist_id)
#
#select *
#from current_playlisting;;
#
```

