Skip to content

Commit f986151

Browse files
Create managed table and external table.
1 parent 36cd0df commit f986151

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

hadoop/edw/hdp/hive/02hive_ddl.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,36 @@ LOCATION '/apps/hive/warehouse/cards.db/deck_of_cards';
2626
-- CREATE DATABASE retail_edw;
2727
-- CREATE DATABASE retail_stage;
2828

29+
-- HDPCD - Define a Hive-managed table
30+
USE retail_stage;
31+
CREATE TABLE orders_demo (
32+
order_id int,
33+
order_date string,
34+
order_customer_id int,
35+
order_status string
36+
)
37+
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
38+
STORED AS TEXTFILE;
39+
40+
-- HDPCD - Define a Hive external table
41+
-- Download the data from github, unzip and copy deckofcards.txt
42+
-- Run on terminal on your PC/Mac to copy data to sandbox
43+
-- scp ./Documents/Training/GoogleDrive/Training/data/cards/deckofcards.txt root@sandbox.hortonworks.com:~
44+
-- On sandbox
45+
hadoop fs -mkdir /user/root/cards
46+
hadoop fs -put deckofcards.txt /user/root/cards
47+
hadoop fs -ls /user/root/cards
48+
-- launch hive by running "hive"
49+
CREATE DATABASE IF NOT EXISTS cards;
50+
USE cards;
51+
CREATE EXTERNAL TABLE deck_of_cards_external
52+
(color string,
53+
suit string,
54+
pip string)
55+
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|'
56+
LOCATION '/user/root/cards';
57+
58+
2959
-- Create ods tables (mostly they will follow same structure, except additional audit columns)
3060
use retail_ods;
3161
CREATE TABLE categories (

0 commit comments

Comments
 (0)