-
Notifications
You must be signed in to change notification settings - Fork 2
/
Spark-SQL.txt
53 lines (40 loc) · 1.27 KB
/
Spark-SQL.txt
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
issue spark-sql or hive command in command line not in pyspark
create database rp_db_txt;
use rp_retail_db_txt;
create table orders (
order_id int,
order_date string,
order_customer_id int,
order_status string
) row format delimited fields terminated by ','
stored as textfile;
load data local inpath '/data/retail_db/orders' into table orders;
create table order_items (
order_item_id int,
order_item_order_id int,
order_item_product_id int,
order_item_quantity int,
order_item_subtotal float,
order_item_product_price float
) row format delimited fields terminated by ','
stored as textfile;
load data inpath /public/data/retail_db/order_items/' overwrite into table order_items;
overwrite -> will delete the existing data and load the data
create database rp_retail_db_orc;
use rp_retail_db_orc;
create table orders (
order_id int,
order_date string,
order_customer_id int,
order_status string
) stored as orc;
insert into table orders select * from rp_retail_db_txt.orders;
create table order_items (
order_item_id int,
order_item_order_id int,
order_item_product_id int,
order_item_quantity int,
order_item_subtotal float,
order_item_product_price float
) stored as orc;
insert into table order_items select * from rp_retail_db_txt.order_items;