Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concat Avro files using avro-tools

Im trying to merge avro files into one big file, the problem is concat command does not accept the wildcard

hadoop jar avro-tools.jar concat /input/part* /output/bigfile.avro

I get:

Exception in thread "main" java.io.FileNotFoundException: File does not exist: /input/part*

I tried to use "" and '' but no chance.

like image 334
54l3d Avatar asked Jan 18 '16 14:01

54l3d


2 Answers

I quickly checked Avro's source code (1.7.7) and it seems that concat does not support glob patterns (basically, they call FileSystem.open() on each argument except the last one).

It means that you have to explicitly provide all the filenames as argument. It is cumbersome, but following command should do what you want:

IN=$(hadoop fs -ls /input/part* | awk '{printf "%s ", $NF}')
hadoop jar avro-tools.jar concat ${IN} /output/bigfile.avro

It would be a nice addition to add support of glob pattern to this command.

like image 53
Clément MATHIEU Avatar answered Sep 19 '22 00:09

Clément MATHIEU


Instead of hadoop jar avro-tools.jar one can run java -jar avro-tools.jar, since you don't need hadoop for this operation.

like image 24
Vlad Patryshev Avatar answered Sep 20 '22 00:09

Vlad Patryshev