-
Notifications
You must be signed in to change notification settings - Fork 16
/
load_hive.sql
85 lines (77 loc) · 4.03 KB
/
load_hive.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
84
85
!hdfs dfs -rm -f -r /tmp/orc_test;
!hdfs dfs -mkdir -p /tmp/orc_test/web_returns_csv;
!hdfs dfs -mkdir -p /tmp/orc_test/web_returns_orc;
!hdfs dfs -copyFromLocal samples/tpcds_web_returns.csv /tmp/orc_test/web_returns_csv;
!hdfs dfs -copyFromLocal tpcds_web_returns.orc /tmp/orc_test/web_returns_orc;
create database if not exists orc_test;
use orc_test;
drop table if exists web_returns_csv;
create external table web_returns_csv
(
wr_returned_date_sk int ,
wr_returned_time_sk int ,
wr_item_sk int ,
wr_refunded_customer_sk int ,
wr_refunded_cdemo_sk int ,
wr_refunded_hdemo_sk int ,
wr_refunded_addr_sk int ,
wr_returning_customer_sk int ,
wr_returning_cdemo_sk int ,
wr_returning_hdemo_sk int ,
wr_returning_addr_sk int ,
wr_web_page_sk int ,
wr_reason_sk int ,
wr_order_number int ,
wr_return_quantity int ,
wr_return_amt decimal(7,2) ,
wr_return_tax decimal(7,2) ,
wr_return_amt_inc_tax decimal(7,2) ,
wr_fee decimal(7,2) ,
wr_return_ship_cost decimal(7,2) ,
wr_refunded_cash decimal(7,2) ,
wr_reversed_charge decimal(7,2) ,
wr_account_credit decimal(7,2) ,
wr_net_loss decimal(7,2)
)
row format delimited fields terminated by '|'
location '/tmp/orc_test/web_returns_csv';
drop table if exists web_returns_orc;
create external table web_returns_orc
(
wr_returned_date_sk int ,
wr_returned_time_sk int ,
wr_item_sk int ,
wr_refunded_customer_sk int ,
wr_refunded_cdemo_sk int ,
wr_refunded_hdemo_sk int ,
wr_refunded_addr_sk int ,
wr_returning_customer_sk int ,
wr_returning_cdemo_sk int ,
wr_returning_hdemo_sk int ,
wr_returning_addr_sk int ,
wr_web_page_sk int ,
wr_reason_sk int ,
wr_order_number int ,
wr_return_quantity int ,
wr_return_amt decimal(7,2) ,
wr_return_tax decimal(7,2) ,
wr_return_amt_inc_tax decimal(7,2) ,
wr_fee decimal(7,2) ,
wr_return_ship_cost decimal(7,2) ,
wr_refunded_cash decimal(7,2) ,
wr_reversed_charge decimal(7,2) ,
wr_account_credit decimal(7,2) ,
wr_net_loss decimal(7,2)
)
stored as orc
location '/tmp/orc_test/web_returns_orc';
select count(*) from web_returns_csv;
select count(*) from web_returns_orc;
select avg(wr_fee) from web_returns_csv;
select avg(wr_fee) from web_returns_orc;
select count(*) from web_returns_csv where wr_fee is null;
select count(*) from web_returns_orc where wr_fee is null;
select count(*) from web_returns_csv where wr_refunded_customer_sk is null;
select count(*) from web_returns_orc where wr_refunded_customer_sk is null;
select wr_fee from web_returns_csv limit 10;
select wr_fee from web_returns_orc limit 10;