sriram var
sriram var

Reputation: 31

HDFS path to load data to Hive

I am running hadoop as a single node distribution. Following the posts i moved a file to HDFS using

hadoop fs -put <local path>    </usr/tmp/fileNAme.txt> .

Now I am trying to load the data from HDFS file to Hive table using the command below . Not able to find out what is the HDFS path relative to my local file system that i should be providing in the command below.

Load Command I am using from my java program to load the hive table is

LOAD DATA IN PATH ('HDFS PATH as it relates to my local File System???' ). All my attempts in giving the path including /usr/tmp/fileNAme.txt fails.

How do I resolve the full HDFS path?

Upvotes: 1

Views: 5275

Answers (3)

prashanthp
prashanthp

Reputation: 85

The syntax for loading file from hdfs into hive is

LOAD DATA INPATH './examples/files/kv1.txt' OVERWRITE INTO TABLE pokes;

Please clarify how do i resolve the full HDFS path .

the full hdfs path in your syntax would be

hdfs://<namenode-hostname>:<port>/your/file/path

Upvotes: 0

Ravindra babu
Ravindra babu

Reputation: 38910

This command loads data from local file system

LOAD DATA LOCAL INPATH './examples/files/kv1.txt' OVERWRITE INTO TABLE pokes;

'LOCAL' signifies that the input file is on the local file system. If 'LOCAL' is omitted then it looks for the file in HDFS.

This command loads data from HDFS file system.

LOAD DATA INPATH './examples/files/kv1.txt' OVERWRITE INTO TABLE pokes;

Have a look into this article for more details.

Upvotes: 1

Durga Viswanath Gadiraju
Durga Viswanath Gadiraju

Reputation: 3956

Syntax is incorrect

 load data local inpath '/tmp/categories01.psv' overwrite into table categories;

You have to specify local inpath in the command.

Upvotes: 1

Related Questions