在猪中加载多个文件 [英] Load multiple files in pig

查看:30
本文介绍了在猪中加载多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚接触猪.

在 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 的 globbing,因此您可以使用的内容取决于底层 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

这篇关于在猪中加载多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆