0

Until hive 0.13 version I was able to add a file to a particular partition of a hive table using the below command :

alter table table add partition (year=2016,month=07,day=25,file_part=1) location '/home/user/data/201607/NetworkActivity_553_1051924_07-25-2016.log.gz';

Our cluster got updated and hive is now hive 1.2 version. I am unable to execute the above command as it throws out the below error :

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:maprfs:/home/user/data/201607/NetworkActivity_553_1051924_07-25-2016.log.g is not a directory or unable to create one)

Could you please let me know that from hive 1.2 version we can only add directories to partition?

K S Nidhin
  • 2,622
  • 2
  • 22
  • 44

1 Answers1

0

Partition location should be directory. Create partition with location=some_directory first then put files into directory. Or put files into some directory then alter table add partition with location = directory.

In your example this is like this:

alter table table add partition (year=2016,month=07,day=25,file_part=1) location '/home/user/data/201607';
leftjoin
  • 36,950
  • 8
  • 57
  • 116
  • I just want to know if there has been a change from hive 0.13 version to hive 1.2 version. As I have mentioned in the question I was able to add files in particular to a partition , which right now I am not able to due to version change. – K S Nidhin Jul 28 '16 at 17:43
  • As far as I know It was always the same. Before .13 version and after. Partition is a folder. I'm working on Hortonworks. Probably it was a bug in your previous Hive version that allowed you to add files instead of folders. – leftjoin Jul 28 '16 at 19:06
  • @KSNidhin: have you tried the approach suggested by @leftjoin? Is it working ? – Ram Ghadiyaram Jul 29 '16 at 11:51