Hadooping: Hive

Credit: Matthew T Rader

Why Hive?

What is Hive?

How to Hive?

CREATE TABLE myFirstTable
( id INT, name STRING, city STRING, items ARRAY<STRING> )
PARTITIONED BY (age INT)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '|'
COLLECTION ITEMS TERMINATED BY ':'
STORED AS TEXTFILE

We have defined, now lets manipulate

LOAD DATA LOCAL INPATH 'path/goes/here/data.dat' OVERWRITE INTO TABLE nameOfTable
LOAD DATA LOCAL INPATH 'path/goes/here/data.dat' OVERWRITE INTO TABLE nameOfTable PARTITION (condition - 'ofPartition')
INSERT OVERWRITE LOCAL DIRECTORY 'please/put/it/here/foldername' 
SELECT sale_id, product, date
FROM sales
WHERE date='2019-01-01'
SELECT * FROM nameOfTable LIMIT 3
SELECT id, name FROM nameOfTable LIMIT 3
SELECT id, name FROM nameOfTable 
WHERE name = 'acgoff' ;
SELECT id, name FROM nameOfTable 
WHERE name = 'acgoff'
GROUP BY city;
SELECT c.ID, c.NAME, c.AGE, o.AMOUNT 
FROM CUSTOMERS c JOIN ORDERS o
ON (c.ID = o.CUSTOMER_ID);

Let’s Review

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store