How to give custom name to Sqoop output files

妖精的绣舞 提交于 2020-01-04 17:33:06

问题


When I import data to hive using sqoop bydefault it creates file name as part-m-0000, part-m-0001 etc on HDFS.

Is it possible to rename these files?

If i wish to give some meaningfull name like suffxing file name with date to indicate load how can I do it?

Please suggest


回答1:


You can't do it with sqoop directly, but you can rename them in HDFS after sqoop is done importing:

today=`date +%Y-%m-%d`
files=$(hadoop fs -ls /path-to-files | awk  '{print $8}')
for f in $files; do hadoop fs -mv $f $f$today; done

The first command gets today's date. The second command gets all the filenames within your directory. The third command renames those files, appending the date.




回答2:


Yes we can ! see here

sqoop import -D mapreduce.output.basename=`date +%Y-%m-%d`


来源:https://stackoverflow.com/questions/28695790/how-to-give-custom-name-to-sqoop-output-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!