gpt4 book ai didi

java - 在 java 中对整个脚本运行 pig explain 命令

转载 作者:行者123 更新时间:2023-11-30 06:25:59 24 4
gpt4 key购买 nike

我正在尝试找到在 java 中对整个 pig 脚本运行解释命令的方法。我使用的是 PigServer,但它只提供对单个查询(别名)而不是整个脚本的解释。有没有办法做这样的事情:

$ pig -x local -e 'explain -script Temp1/TPC_test.pig -out explain-out9.txt'

但是来 self 的 Java 代码?

最佳答案

您可以使用 PigRunner为此目的。
例如:

import org.apache.pig.PigRunner;
import org.apache.pig.tools.pigstats.PigStats;

public class PigTest {

public static void main(String[] args) throws Exception {

args = new String [] {
"-x", "local",
"-e", "explain -script Temp1/TPC_test.pig -out explain-out9.txt"
};

PigStats stats = PigRunner.run(args, null);
//print plan:
//stats.getJobGraph().explain(System.out, "text", true);
}

}

我发现需要以下运行时依赖项来避免NoClassDefFoundError:

关于java - 在 java 中对整个脚本运行 pig explain 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14938735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com