Some stuff
This commit is contained in:
parent
ba37fc09e7
commit
63411b6190
4 changed files with 40 additions and 2 deletions
|
|
@ -16,7 +16,7 @@ CREATE DATABASE airbnb;
|
|||
|
||||
CREATE SCHEMA raw;
|
||||
|
||||
-- The following tables should be created in the `raw` schema
|
||||
-- The following tables should be created in the `src` schema
|
||||
|
||||
CREATE TABLE raw_listings (
|
||||
id INTEGER,
|
||||
|
|
@ -53,7 +53,7 @@ CREATE SCHEMA dev;
|
|||
-- Create a user for dbt activity
|
||||
CREATE USER transformation_user WITH ENCRYPTED PASSWORD 'transformation_user_password';
|
||||
|
||||
-- Allow dbt user to read from raw schema
|
||||
-- Allow dbt user to read from src schema
|
||||
GRANT CONNECT ON DATABASE airbnb TO transformation_user;
|
||||
GRANT USAGE ON SCHEMA raw TO transformation_user;
|
||||
GRANT SELECT ON ALL TABLES IN SCHEMA raw TO transformation_user;
|
||||
|
|
|
|||
20
code_thingies/dbtlearn/models/src/src_listings.sql
Normal file
20
code_thingies/dbtlearn/models/src/src_listings.sql
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
WITH raw_listings AS (
|
||||
SELECT *
|
||||
FROM raw.raw_listings
|
||||
)
|
||||
SELECT
|
||||
id AS listing_id,
|
||||
name AS listing_name,
|
||||
listing_url,
|
||||
room_type,
|
||||
minimum_nights,
|
||||
host_id,
|
||||
price AS price_str,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
raw_listings
|
||||
|
||||
|
||||
|
||||
|
||||
11
code_thingies/dbtlearn/models/src/src_reviews.sql
Normal file
11
code_thingies/dbtlearn/models/src/src_reviews.sql
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
WITH raw_reviews AS (
|
||||
SELECT *
|
||||
FROM raw.raw_reviews
|
||||
)
|
||||
SELECT
|
||||
listing_id,
|
||||
date AS review_date,
|
||||
comments AS review_text,
|
||||
sentiment AS review_sentiment
|
||||
FROM
|
||||
raw_reviews
|
||||
Loading…
Add table
Add a link
Reference in a new issue