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

问题描述

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

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

推荐答案

这个想法是将你的输入行转换成一个包,然后将它压平.这里可能有两种情况:

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

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

10-10 20:31