3

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??

RAVITEJA SATYAVADA
  • 2,503
  • 23
  • 56
  • 88

7 Answers7

12

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

Balaswamy Vaddeman
  • 8,360
  • 3
  • 30
  • 40
  • The link is not working anymore. Would anyone care to update it? And I guess `sample` is the name of the table? Thanks. – Bowen Liu Aug 12 '20 at 14:44
3

Backslashes may be problem here. Try:

load data inpath "D:/data files/sample.txt" into table sample;
ghan25
  • 41
  • 7
1

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;

Anoop
  • 21
  • 3
0

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.

Venu A Positive
  • 2,992
  • 2
  • 28
  • 31
0

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

Naag
  • 11
0

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.

0

when you want to load data from Edge node to HDFS you have to go for

load data local inpath '/user/cloudera/datah/txns' into table txn_externalh;

when you want to load data from HDFS node to HIVE you have to go for

load data inpath '/user/cloudera/datah/txns' into table txn_externalh;

Satish Gs
  • 1
  • 1