在Pig中加载多个文件 [英] Load multiple files in pig
问题描述
我是猪的新手.
在Pig中,我想加载多个带有时间戳的文件.
In pig, I want to load multiple files with timestamps at their names.
如果我在2012/02/12至2012/02/19之间加载文件,则可以进行以下操作
If I load files between 2012/02/12 to 2012/02/19, the following works
$START = "12"
$END = "19"
raw_data = load '/table/status/2012/02/{$START,$END}' using Loader()
假设开始日期是2011/12/29,结束日期是2012/01/04,如何更改代码行?
Suppose the start date is 2011/12/29 and end date is 2012/01/04, how do I change the line of code?
感谢您的帮助!
推荐答案
可以使用以下glob来加载所需范围:
The range you need can be loaded by using the following globs:
raw_data = load '/table/status/{2011/12/{29,3{0,1}},2012/01/0[1-4]}' using Loader()
请注意,Pig使用Hadoop的全局机制,因此您可以使用的内容取决于基础HDFS的版本.在0.20以下有效.
Note, that Pig uses Hadoop's globbing so what you can use depends on the version of the underlying HDFS. This works under 0.20.
如果需要更复杂的范围,则目录枚举的这种方式可能有点不灵活.因此,请考虑按照建议的方式使用Shell脚本收集所需的目录
If a more complex range is needed then this way of directory enumeration might be a bit inflexible. Therefore consider using a shell script to gather the directories you need as suggested here
这篇关于在Pig中加载多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!