问题
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