Tuesday, July 12, 2016

How to load data from HDFS into Vertica

Through Copy Command

Data:(hdfsdata.txt) ( delimited by space)

1 amazon
2 google
3 microsoft

 

drop table if exists test.hdfsdata;

create table  test.hdfsdata(
col1 int, 
col2 varchar(100)
);

hadoop fs -put hdfsdata.txt  /user/tickmoh/test/.


vsql> COPY test.hdfsdata SOURCE Hdfs(url='localhost:50070/webhdfs/v1/user/tickmoh/test/hdfsdata.txt', username='tickmoh')  DELIMITER  AS ' ' NULL AS 'null';

 

Through External table

 
drop table if exists test.hdfsdata_ext;
create external table  test.hdfsdata_ext(
col1 int,
col2 varchar(100)
)
AS COPY SOURCE Hdfs(url='localhost:50070/webhdfs/v1/user/tickmoh/test/hdfsdata.txt', username='tickmoh')  DELIMITER  AS ' ' NULL AS 'null';

 

localhost should be your hadoop host