私はブタユニットテストをセットアップしようとしています。私はsvnトランクに切り替えたので、少し古くなっているようです。最初の奇妙なことは、実際には、動作させるために、ピグニット、ブタ、ハープ・コモンだけでなく、もっと多くのlibsが必要であるということです(hadoop-hdfs、hadoop-mapreduce-client-core、hadoop-mapreduce-client-jobclientを追加する)。私は自分の依存マネージャーでこれらを持つことは良いことだとは確信していませんが、これは主要な問題ではありません。pigunitサンプルテストを実行する際に異常なエラーが発生しました
@Test
public void testNtoN() throws ParseException, IOException {
String[] args = {
"n=3",
"reducers=1",
"input=top_queries_input_data.txt",
"output=top_3_queries",
};
test = new PigTest("script dir", args);
String[] output = {
"(yahoo,25)",
"(facebook,15)",
"(twitter,7)",
};
test.assertOutput("queries_limit", output);
}
そして、ここで実際のスクリプトです::だからここに私が実行しようとしているテストです
data =
LOAD '$input'
AS (query:CHARARRAY, count:INT);
queries_group =
GROUP data
BY query
PARALLEL $reducers;
queries_sum =
FOREACH queries_group
GENERATE
group AS query,
SUM(data.count) AS count;
queries_ordered =
ORDER queries_sum
BY count DESC
PARALLEL $reducers;
queries_limit = LIMIT queries_ordered $n;
STORE queries_limit INTO '$output';
は、ここにスタックトレースです:
STORE queries_limit INTO 'top_3_queries';
--> none
org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1066: Unable to open iterator for alias queries_limit
at org.apache.pig.PigServer.openIterator(PigServer.java:1019)
at org.apache.pig.pigunit.PigTest.getAliasFromCache(PigTest.java:224)
at org.apache.pig.pigunit.PigTest.getActualResults(PigTest.java:319)
at org.apache.pig.pigunit.PigTest.assertOutput(PigTest.java:409)
at org.apache.pig.pigunit.PigTest.assertOutput(PigTest.java:400)
at BlaUnitTest.testBla(BlaUnitTest.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.io.IOException: Couldn't retrieve job.
at org.apache.pig.PigServer.store(PigServer.java:1083)
at org.apache.pig.PigServer.openIterator(PigServer.java:994)
... 34 more
私が何を見て、それをデバッグしようとしましたこれはクエリプランを作成してExecJobを取得しようとしたときに発生しますが、それを把握することはできませんでした。私はスクリプトを単純化し、データをロードして保存するためのコード以外のすべてを削除しようとしました。結果は同じでした。
デフォルトではPigStorageを使用して読み込みが行われ、\ tは使用されるデフォルトの区切り文字です。 top_queries_input_data.txtはそれに応じて区切られていますか? hadoop-mapreduce- *ライブラリを含めてあなたの質問をWRTすれば、テストのためだけにそれらを含めることができます。依存関係管理にgradleを使用している場合は、testCompileを使用できます。私は、依存関係の管理で同様のことを行う方法があると確信しています。 – coder
はい、私は彼らのsvn(http://svn.apache.org/viewvc/pig/trunk/test/data/pigunit/)の正確なデータを使用しています。そして私は問題がPigServerのいくつかの設定に関係していると思っています(私はLOCALモードでそれを実行していますが、いくつかの追加の設定があるかもしれません)、あるいはOSに関連しているかもしれません。(私はUbuntu 14.04を使用しています) –
問題の絞り込みに役立つスタックトレースを提供していますか?また、これはすべて記憶されているので、設定が必要なのかどうか疑問です。 – coder