## get_all_playlists.r


get_all_playlists <- function(wh=getSnowflakeWH(), dbname=getSnowflakeDB(), ..., cluster=NULL, snowflake_inuse=getOption("snowflake_inuse"), verbose=TRUE) { 
## Queries the database for ALL DISTINCT source_uri in the system
## 50K as of 2015-June
  tbl <- "staging_raw_spotify_v2"
  schema <- "production"

  makeQry(colsToPull="source_uri", distinct=TRUE, aggFunc=NULL, tbl=tbl, schema=schema, limit=NULL, wh=wh, dbname=dbname, snowflake_inuse=snowflake_inuse, ...) %>%
  runQry(cluster=cluster, wh=wh, dbname=dbname, snowflake_inuse=snowflake_inuse, verbose=verbose) %>% .[["source_uri"]] %>% setdiff("")
}


## ------------------ ##
##   TEST    
## ------------------ ##
if (FALSE) 
{
  playlists.all <- get_all_playlists()

  ## confirm all of the expected pattern
  pat <- "^spotify:user:.+?:playlist:.+?$"
  grepl(pat, playlists.all) %>% all
}

