从其他 Pig 脚本调用 Pig Latin 脚本 [英] Invoke Pig Latin script from other Pig script

查看:31
本文介绍了从其他 Pig 脚本调用 Pig Latin 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 PIG Latin 的问题.有什么办法可以从另一个猪脚本中调用一些猪脚本吗?

I have a question about PIG Latin. Is there any way how to invoke some pig script from the other pig script?

我知道可以运行用户定义的函数 (UDF),例如:

I know it is possible to run user defined functions (UDFs) like:

REGISTER myudfs.jar;
A = LOAD 'student_data' AS (name: chararray, age: int, gpa: float);
B = FOREACH A GENERATE myudfs.UPPER(name);
DUMP B;

但它不适用于猪脚本.我们正在计算一些不同的客户参数,为了可读性和重用,加载一些猪片段会很棒,例如:

But it is not working for pig script. We are counting some different customer parameters and for readibility and reuse it would be great to load some pig snippets, something like:

REGISTER somepigscript.pig;
LOAD somepigscript.pig;

不知道有没有这样的功能?或者任何 UDF?

Do you know if there is any functionality like this? Or any UDF?

谢谢你,祝你有美好的一天...

Thank you and have a good day...

推荐答案

Pig 有两个命令,RUNEXEC.它们的不同之处在于 RUN 将执行 Pig 脚本并保留其别名和属性供后续使用,而 EXEC 仅执行脚本并返回调用环境不变(但在 HDFS 上创建的任何新文件都可用).

Pig has two commands, RUN and EXEC. They differ in that RUN will execute the Pig script and leave its aliases and properties available for subsequent usage, while EXEC simply executes the script and returns with the calling environment unaltered (but with any new files created on HDFS available).

例如,我有一组宏、jar 和属性,我想在我编写的每个脚本的开头设置它们.我没有每次都输入它们,而是将其放入 Pig 脚本中,并在脚本的开头调用 RUN/my/script.pig.

For example, I have a collection of macros, jars, and properties that I want to set at the beginning of every single script I write. Rather than type them every time, I put that into a Pig script and call RUN /my/script.pig at the beginning of my scripts.

这篇关于从其他 Pig 脚本调用 Pig Latin 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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