Этап 3. Слой Core — обогащённые данные. Пет проект: DWH. РАБОТА НАД ОШИБКАМИ - сделали типы столбцов в core такими же как в raw.
This commit is contained in:
@@ -1,27 +1,27 @@
|
|||||||
-- 4
|
-- 4
|
||||||
|
|
||||||
--DROP TABLE IF EXISTS core.dim_user;
|
--DROP TABLE IF EXISTS core.dim_user;
|
||||||
CREATE TABLE core.dim_user (
|
CREATE TABLE core.dim_user (
|
||||||
user_id int PRIMARY KEY,
|
user_id bigint PRIMARY KEY,
|
||||||
name text,
|
name varchar(100),
|
||||||
age int,
|
age smallint,
|
||||||
email text NOT NULL,
|
email varchar(100) NOT NULL,
|
||||||
registration_date date NOT NULL
|
registration_date timestamptz NOT NULL
|
||||||
) DISTRIBUTED BY (user_id);
|
) DISTRIBUTED BY (user_id);
|
||||||
|
|
||||||
--DROP TABLE IF EXISTS core.dim_course;
|
--DROP TABLE IF EXISTS core.dim_course;
|
||||||
CREATE TABLE core.dim_course (
|
CREATE TABLE core.dim_course (
|
||||||
course_id int PRIMARY KEY,
|
course_id bigint PRIMARY KEY,
|
||||||
title text NOT NULL,
|
title varchar(150) NOT NULL,
|
||||||
category text
|
category varchar(50),
|
||||||
|
created_at timestamptz NOT NULL
|
||||||
) DISTRIBUTED BY (course_id);
|
) DISTRIBUTED BY (course_id);
|
||||||
|
|
||||||
--DROP TABLE IF EXISTS core.dim_lesson;
|
--DROP TABLE IF EXISTS core.dim_lesson;
|
||||||
CREATE TABLE core.dim_lesson (
|
CREATE TABLE core.dim_lesson (
|
||||||
lesson_id int PRIMARY KEY,
|
lesson_id bigint PRIMARY KEY,
|
||||||
title text NOT NULL,
|
title varchar(150) NOT NULL,
|
||||||
duration_min int,
|
duration_min smallint,
|
||||||
course_id int NOT NULL REFERENCES core.dim_course(course_id)
|
course_id bigint NOT NULL REFERENCES core.dim_course(course_id)
|
||||||
) DISTRIBUTED BY (lesson_id);
|
) DISTRIBUTED BY (lesson_id);
|
||||||
|
|
||||||
--DROP TABLE IF EXISTS core.dim_date;
|
--DROP TABLE IF EXISTS core.dim_date;
|
||||||
@@ -37,17 +37,17 @@ CREATE TABLE core.dim_date (
|
|||||||
-- 5
|
-- 5
|
||||||
--DROP TABLE IF EXISTS core.fact_lesson_views;
|
--DROP TABLE IF EXISTS core.fact_lesson_views;
|
||||||
CREATE TABLE core.fact_lesson_views (
|
CREATE TABLE core.fact_lesson_views (
|
||||||
user_id int NOT NULL REFERENCES core.dim_user(user_id),
|
user_id bigint NOT NULL REFERENCES core.dim_user(user_id),
|
||||||
lesson_id int NOT NULL REFERENCES core.dim_lesson(lesson_id),
|
lesson_id bigint NOT NULL REFERENCES core.dim_lesson(lesson_id),
|
||||||
course_id int NOT NULL REFERENCES core.dim_course(course_id),
|
course_id bigint NOT NULL REFERENCES core.dim_course(course_id),
|
||||||
viewed_at timestamp NOT NULL
|
viewed_at timestamptz NOT NULL
|
||||||
) DISTRIBUTED BY (user_id);
|
) DISTRIBUTED BY (user_id);
|
||||||
|
|
||||||
--DROP TABLE IF EXISTS core.enrollments;
|
--DROP TABLE IF EXISTS core.enrollments;
|
||||||
CREATE TABLE core.enrollments (
|
CREATE TABLE core.enrollments (
|
||||||
user_id int NOT NULL REFERENCES core.dim_user(user_id),
|
user_id bigint NOT NULL REFERENCES core.dim_user(user_id),
|
||||||
course_id int NOT NULL REFERENCES core.dim_course(course_id),
|
course_id bigint NOT NULL REFERENCES core.dim_course(course_id),
|
||||||
enrolled_at timestamp NOT NULL
|
enrolled_at timestamptz NOT NULL
|
||||||
) DISTRIBUTED BY (user_id);
|
) DISTRIBUTED BY (user_id);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user