Documente Academic
Documente Profesional
Documente Cultură
2.
123456,001
456123,002
789123,003
789456,004
UserName, delivery Status Code Description
------------------------------------------------jim,
Delivered
---------------------------------------------------------------------------------------------------------------------------------creating Hive tables to store the files
create TABLE customer_details (cellNumber String,consumerName String)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY',';
LOAD DATA LOCAL INPATH '/user/root/userDetails.txt' INTO TABLE customer_detail
s;
CREATE TABLE delivery_report (cellNumber String,statusCode int)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY',';
LOAD DATA LOCAL INPATH '/user/root/DeliveryStatusCode.txt' INTO TABLE status_c
odes;
SELECT word , COUNT(*) FROM doc LATERAL VIEW explode(split(text,' ')) xTab
le as word GROUP BY word;
hadoop
hadoop
hadoop
hadoop
fs
fs
fs
fs
-ls
-ls
-ls
-ls
/apps/hive
/apps/hive/warehouse
/apps/hive/warehouse/battin/
/apps/hive/warehouse/battin/
// will fail
hive> LOAD DATA LOCAL INPATH '/root/ravi/president.txt' OVERWRITE INTO TABLE pr
esident partition (country='USA');
$hadoop fs -ls /aaps/hive/warehouse/president
$hadoop fs -ls /aaps/hive/warehouse/president/country=USA
// after that we past 2 more file in winscp Presidentindia , presidentrussia
hive> LOAD DATA LOCAL INPATH '/root/ravi/president.txt' OVERWRITE INTO TABLE p
resident partition (country='india');
hive> LOAD DATA LOCAL INPATH '/root/ravi/president.txt' OVERWRITE INTO TABLE p
resident partition (country='russia');
//to see out put
hive> show partitions president;
hive> select * from president where country='USA';
hive> select * from president where country='india';
hive> select * from president where country='russia';
----------------------------------------------------------------------------------------------------------------------------------------------------HCatalog
_____________
if you are a hive user , you can use your hive metastore with no modificati
ons
type $ hcat -e
$ hcat -e "create table rawevent (url string, user string) partitioned by (
ds string);";
grunt> a = LOAD 'rawevent' using org.apache.hcatalog.pig.HcatLoader();
--------------------------------------------------------------------------------------------------------------------------------------------SQOOP
1 . $ sql (launch mysql on command prompt to start sql it's alredy in sandbox
)
2.
show databases ;
3.
use test;
4.
5.
6.
7.