从Pig中的单行输入生成多行输出 [英] Generating multiple lines output from single line input in pig

查看:137
本文介绍了从Pig中的单行输入生成多行输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是通过在Pig脚本中使用单行输入来生成多行输出.有什么可能的解决方案?

My requirement is to generate multiple lines of output by using single line of input in pig scripting. What are the possible solutions?

推荐答案

该想法是将输入行转换为包,然后将其展平.这可能是2种情况:

The idea is to convert you input line into a bag and then flatten it. Here could be 2 cases:

阅读文字:

txt = load '/pig_fun/input/text.txt' using TextLoader();
words = foreach txt generate TOKENIZE($0);
pivoted = foreach words generate FLATTEN($0);
dump pivoted;

输入:

My requirement is to generate multiple lines of output by using single line of input in pig scripting.
What are the possible solutions?

输出:

(My)
(requirement)
(is)
(to)
(generate)
(multiple)
(lines)
(of)
(output)
(by)
(using)
(single)
(line)
(of)
(input)
(in)
(pig)
(scripting.)
(What)
(are)
(the)
(possible)
(solutions?)

阅读列,然后对其进行透视,请参见使用Apache Pig的透视表

Reading columns and then pivoting them see Pivot table with Apache Pig

这篇关于从Pig中的单行输入生成多行输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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