Python スクリプトに埋め込まれた pig を実行中に Python エラーが発生しました。問題は解決しましたが、他の誰かがこのエラーに遭遇したかどうかを知りたい.
シナリオ: a) pig を使用した Python スクリプトは次のようになります。
pigRun = Pig.compileFromFile(self.settingsReader.getScriptsDir() + "/" + script.name)
params = { 'datefrom': '2012-08-04 00:00:00', 'dateto': '2012-12-05 00:00:00',
'parallelism':self.settingsReader.getParallelism(),
'input' : script.input, 'output':script.output}
bound = pigRun.bind(params)
stats=bound.runSingle()
if not stats.isSuccessfull():
raise 'failed'
b) 豚のバージョンは 0.10 です。Python 2.7、Jython 2.5 行でエラーが発生する
if not stats.isSuccessfull():
raise 'failed'
c) エラーは次のとおりです AttributeError: 'org.apache.pig.tools.pigstats.SimplePigStats' object has no attribute 'isSuccessfull'
Apache PIG 0.10 のソースを見ると、SimplePigStats には isSuccessfull() が実装されているようです。しかし、実行時エラーはそうではないと言っています。
暫定的な解決策: 障害チェック コードを次のように変更しました。
bound = pigRun.bind(params)
stats= bound.runSingle()
if stats.getReturnCode() != 0:
raise 'failed'
これはうまくいくようです。