This repository was archived by the owner on Jun 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 356
Expand file tree
/
Copy pathcreate-db-tb-upload-data.sql
More file actions
58 lines (54 loc) · 1.65 KB
/
create-db-tb-upload-data.sql
File metadata and controls
58 lines (54 loc) · 1.65 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
DECLARE @db_name varchar(255), @tb_name varchar(255)
DECLARE @create_db_template varchar(max), @create_tb_template varchar(max), @create_tb_template2 varchar(max)
DECLARE @sql_script varchar(max)
SET @db_name = 'TaxiNYC_Sample'
SET @tb_name = 'nyctaxi_sample'
SET @create_db_template = 'create database {db_name}'
SET @create_tb_template = '
use {db_name}
CREATE TABLE {tb_name}
(
medallion varchar(50) not null,
hack_license varchar(50) not null,
vendor_id char(3),
rate_code char(3),
store_and_fwd_flag char(3),
pickup_datetime datetime not null,
dropoff_datetime datetime,
passenger_count int,
trip_time_in_secs bigint,
trip_distance float,
pickup_longitude float,
pickup_latitude float,
dropoff_longitude float,
dropoff_latitude float,
payment_type char(3),
fare_amount float,
surcharge float,
mta_tax float,
tolls_amount float,
total_amount float,
tip_amount float,
tipped int,
tip_class int
)
CREATE CLUSTERED COLUMNSTORE INDEX [nyc_cci] ON {tb_name} WITH (DROP_EXISTING = OFF)
'
SET @create_tb_template2 = '
use {db_name}
CREATE TABLE nyc_taxi_models
(
model varbinary(max) not null
)
'
-- Create database
SET @sql_script = REPLACE(@create_db_template, '{db_name}', @db_name)
EXECUTE(@sql_script)
-- Create table
SET @sql_script = REPLACE(@create_tb_template, '{db_name}', @db_name)
SET @sql_script = REPLACE(@sql_script, '{tb_name}', @tb_name)
EXECUTE(@sql_script)
-- Create the table to persist the trained model
SET @sql_script = REPLACE(@create_tb_template2, '{db_name}', @db_name)
EXECUTE(@sql_script)
GO