投影 Pig 中嵌套关系的所有列
我有一个关系 MY_REL,它是 X 和 Y 连接的结果:
MY_REL = {X::x1,X::x2,Y::y1,Y::y2}
我尝试做
Bla = foreach MY_REL generate X;
Pig 呕吐:
ERROR 1000: Error during parsing. Scalars can be only used with projections
我尝试了 X::* 并抛出:无效的别名 X。
丑陋的解决方法:我切换到显式写入所有列名称:
Bla = foreach MY_REL generate X::x1, X::x2;
有没有一种好方法来生成所有 X 的列?
I have a relation MY_REL that is the result of a join of X and Y:
MY_REL = {X::x1,X::x2,Y::y1,Y::y2}
And I tried to do
Bla = foreach MY_REL generate X;
Pig vomited:
ERROR 1000: Error during parsing. Scalars can be only used with projections
I tried X::* and it throws: invalid alias X.
The ugly workaround: I switched to explicitly writing all column names:
Bla = foreach MY_REL generate X::x1, X::x2;
Is there a nice way to generate all X's columns?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要使用
JOIN
,而是使用COGROUP
。COGROUP
将创建一个类似于{X : {x1, x2}, Y : {y1, y2}}
的关系。因此,你可以这样做:注意,里面有一个袋子,所以你想
压平
它。Instead of using
JOIN
, useCOGROUP
.COGROUP
will create a relation that looks like{X : {x1, x2}, Y : {y1, y2}}
. Therefore, you can do:Note that it is a bag in there, so you want to
flatten
it.如果 JOIN 之前的列都具有不同的名称,则可以按如下方式使用它们:
如果只有一个冲突,则需要使用原始前缀关系
An 和新的 Pig 范围 PIG-1693
PIG-2511
If your columns before the JOIN all have a different name, you can just use them as is later:
If only one conflict you need to use the original prefix relation
An with the new Pig range PIG-1693
And there is also some talks in PIG-2511