如何使用通配符投影别名? [英] 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屋!