-
Notifications
You must be signed in to change notification settings - Fork 0
/
05_create_csv_tables.sql
84 lines (74 loc) · 1.6 KB
/
05_create_csv_tables.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
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
72
73
74
75
76
77
78
79
80
81
82
83
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.optimize.sort.dynamic.partition=true;
CREATE DATABASE IF NOT EXISTS hwxdemo;
USE hwxdemo;
drop table if exists flights_csv purge;
drop table if exists airports_csv purge;
drop table if exists airlines_csv purge;
drop table if exists planes_csv purge;
create table airports_csv(
iata string,
airport string,
city string,
state string,
country string,
lat double,
lon double
)
STORED AS TEXTFILE
LOCATION 's3a://hw-sampledata/airline_csv/airline_ontime.db/airports'
;
create table airlines_csv (
code string,
description string
)
STORED AS TEXTFILE
LOCATION 's3a://hw-sampledata/airline_csv/airline_ontime.db/airlines'
;
create table planes_csv (
tailnum string,
owner_type string,
manufacturer string,
issue_date string,
model string,
status string,
aircraft_type string,
engine_type string,
year int
)
STORED AS TEXTFILE
LOCATION 's3a://hw-sampledata/airline_csv/airline_ontime.db/planes'
;
create table flights_csv (
DateOfFlight date,
DepTime int,
CRSDepTime int,
ArrTime int,
CRSArrTime int,
UniqueCarrier string,
FlightNum int,
TailNum string,
ActualElapsedTime int,
CRSElapsedTime int,
AirTime int,
ArrDelay int,
DepDelay int,
Origin string,
Dest string,
Distance int,
TaxiIn int,
TaxiOut int,
Cancelled int,
CancellationCode varchar(1),
Diverted varchar(1),
CarrierDelay int,
WeatherDelay int,
NASDelay int,
SecurityDelay int,
LateAircraftDelay int
)
PARTITIONED BY (Year int)
STORED AS TEXTFILE
LOCATION 's3a://hw-sampledata/airline_csv/airline_ontime.db/flights'
TBLPROPERTIES("orc.bloom.filter.columns"="*")
;