Thursday 14 April 2022

What is the behaviour, when I keep on adding the same file to a HDFS folder?

When you try to add the file again to a same HDFS folder, you will get ‘File exists’ error.

 

Let’s experiment by copying the file emp.csv to some Hadoop location multiple times.

 

emp.csv 

1,Krishna
2,Ram
3,Raheem
4,Joel

 

Create a directory /copyDemo and copy the file emp.csv to it.

[cloudera@quickstart hive]$ hadoop fs -mkdir /copyDemo
[cloudera@quickstart hive]$ 
[cloudera@quickstart hive]$ hadoop fs -copyFromLocal emp.csv /copyDemo
[cloudera@quickstart hive]$ 
[cloudera@quickstart hive]$ hadoop fs -ls /copyDemo
Found 1 items
-rw-r--r--   1 cloudera supergroup         32 2022-04-14 21:41 /copyDemo/emp.csv
[cloudera@quickstart hive]$ 
[cloudera@quickstart hive]$ hadoop fs -cat /copyDemo/*
1,Krishna
2,Ram
3,Raheem
4,Joel

 


 

Let’s copy the file emp.csv again to the folder /copyDemo.

[cloudera@quickstart hive]$ hadoop fs -copyFromLocal emp.csv /copyDemo
copyFromLocal: `/copyDemo/emp.csv': File exists

As you see, you got an error saying emp.csv file exists already.


Previous                                                 Next                                                 Home

No comments:

Post a Comment