-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSongs_Snowpipe.sql
31 lines (25 loc) · 1010 Bytes
/
Songs_Snowpipe.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
CREATE OR REPLACE TABLE SPOTIFY_DB_1.PUBLIC.song_table (
song_id VARCHAR(50),
song_name VARCHAR(255),
duration_ms NUMBER,
url VARCHAR(255),
popularity DATE,
song_added VARCHAR(255),
album_id VARCHAR(50),
artist_id VARCHAR(50)
);
CREATE OR REPLACE STAGE SPOTIFY_DB_1.PUBLIC.aws_songs_stage
URL = 's3://spotify-etl-project-sravya/transformed_data/songs_data/'
STORAGE_INTEGRATION = s3_init
FILE_FORMAT = csv_file_format;
LIST @SPOTIFY_DB_1.PUBLIC.aws_songs_stage;
//Creating the snow pipe and copying the data from the staging area whenever there is new data.
CREATE OR REPLACE pipe SPOTIFY_DB_1.pipes.song_pipe
AUTO_INGEST = TRUE
AS
COPY INTO SPOTIFY_DB_1.PUBLIC.song_table FROM@SPOTIFY_DB_1.PUBLIC.aws_songs_stage/;
//Accessing event notifications from S3
DESC pipe SPOTIFY_DB_1.pipes.song_pipe;
//Checking the updated data
select * from SPOTIFY_DB_1.PUBLIC.song_table;
TRUNCATE TABLE SPOTIFY_DB_1.PUBLIC.song_table;