如何使用通配符投影别名? [英] How to project an alias using a wildcard?

查看:100
本文介绍了如何使用通配符投影别名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦我执行了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 Edescribe 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屋!

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