如何使用通配符投影别名? [英] How to project an alias using a wildcard?
问题描述
一旦我执行了join A by id, B by id
,我将获得一个别名,其中包含字段A::f...
,B::f..
.
有没有一种方法可以将其仅投影在A
字段上?
Once I do a join A by id, B by id
, I get an alias with fields A::f...
, B::f..
.
Is there a way to project it on only the A
fields?
C = join A by id, B by id;
D = filter C by B::n < 1000;
E = foreach D generate A::*;
我知道
Unexpected character '*'
我想要的是E
,其架构为相同到A
(即describe E
和describe A
应该打印完全相同的东西).
What I want is E
with the schema identical to A
(i.e., describe E
and describe A
should print the exact same things).
我该怎么做?
推荐答案
您可以使用项目范围表达式以获取其中的一部分.
You can use a project-range expression to get part of the way there.
不幸的是,没有办法系统地剥离A::
前缀.如果您知道A
的最后一个字段的名称(假设它是last
),则可以执行以下操作:
Unfortunately, there is no way to systematically strip the A::
prefix. If you know the name of the last field of A
(suppose it's last
), you can do this:
E = foreach D generate .. A::last;
如果只需要B
中的字段,则可以
If you wanted just the fields from B
you would do
E = foreach D generate B::first ..;
如果您确实需要应用特定的架构,也许您可以只定义一个在需要时应用该架构的宏,这样您就可以覆盖来自分组,联接等的任何更改.
If you really need to apply a specific schema, perhaps you could just define a macro that applies this schema whenever you need it, so you can overwrite any of the changes that come from grouping, joining, etc.
这篇关于如何使用通配符投影别名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!