-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_trino.sql
More file actions
71 lines (65 loc) · 1.72 KB
/
setup_trino.sql
File metadata and controls
71 lines (65 loc) · 1.72 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
CREATE SCHEMA IF NOT EXISTS hive.problems
WITH (location = 's3a://problems/');
-- Cumulative Distinct Count
CREATE TABLE IF NOT EXISTS hive.problems.hackers (
hacker_id INT,
hacker_name VARCHAR
) WITH (
external_location = 's3a://problems/hackers/',
format = 'PARQUET'
);
CREATE TABLE IF NOT EXISTS hive.problems.submissions (
submission_date DATE,
submission_id INT,
hacker_id INT,
score INT
) WITH (
external_location = 's3a://problems/submissions/',
format = 'PARQUET'
);
-- Cumulative Table Design
CREATE TABLE IF NOT EXISTS hive.problems.user_actions (
event_id VARCHAR,
user_id INT,
country VARCHAR,
event_ts BIGINT,
action VARCHAR
) WITH (
external_location = 's3a://problems/user_actions/',
format = 'PARQUET'
);
CREATE TABLE IF NOT EXISTS hive.problems.users (
user_id INT,
country VARCHAR,
first_login_ts BIGINT,
last_login_ts BIGINT,
user_segment VARCHAR,
partition_date DATE
) WITH (
external_location = 's3a://problems/users/',
format = 'PARQUET'
);
-- One Big Table Design
CREATE TABLE IF NOT EXISTS hive.problems.posts (
post_id INT,
user_id INT,
post_content VARCHAR,
post_time TIMESTAMP,
start_time TIMESTAMP,
end_time TIMESTAMP,
is_deleted BOOLEAN,
is_current BOOLEAN,
partition_date DATE
) WITH (
external_location = 's3a://problems/posts/',
format = 'PARQUET'
);
CREATE TABLE IF NOT EXISTS hive.problems.post_actions (
action_id VARCHAR,
post_id INT,
action VARCHAR,
action_time TIMESTAMP
) WITH (
external_location = 's3a://problems/post_actions/',
format = 'PARQUET'
);