Question

I'm new to Hive and using DBVisualizer for hive

I have a text file in the path *D:\data files\datafiles*. I want to load data from one of the files to a table created in hive. while i'm trying the following,

load data inpath "D:\data files\sample.txt" into table sample;

It is showing error like,

 cause: FAILED: Error in semantic analysis: Line 1:17 Invalid path "D:\data files\sample.txt": only "file" or "hdfs" file systems accepted

How can proceed, to place that file in correct path and where to place it??

Was it helpful?

Solution

either you can upload that file into hdfs and try same command with hdfs path.

or

you may use local keyword as below.

load data local inpath "D:\data files\sample.txt" into table sample;

check this for more details

OTHER TIPS

Backslashes may be problem here. Try:

load data inpath "D:/data files/sample.txt" into table sample;

If you are loading data from your local machine to HDFS we have to use "LOCAL" in load data command: load data LOCAL inpath "D:\data files\sample.txt" into table sample;

There are two ways to load the data.

First load data from local and another load from HDFS... but the path is vary on the OS. If you load data from Linux:

load data local inpath '/home/local/path/sample.txt' into table sample.//Local path

load data inpath '/home/hadoop/path/sample.txt' into table sample.// Hadoop path

If in windows:

load data inpath "D:/data files/sample.txt" into table sample; //Here carefully observe / not \ ok.

load data local inpath "D:/data files/sample.txt" into table sample; //local path it is

Check once.

load data local inpath "D:\data files\sample.txt" into table sample;

by using above command it looks for hdfs location but mentioned path is local environment So use below command then only we can solve the issue

load data local inpath "D:\data files\sample.txt" overwrite into table sample;

By using above command data overwrited into mentioned table

You might not have stored sample.txt file as ".txt" file.

Please check if the file is saved properly as ".txt" file and try again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top