2015-08-28 56 views
0

我寫了一個非常簡單的Python,這裏是我的UDF代碼,豬代碼和錯誤消息,任何想法是什麼錯?謝謝。簡單的Python UDF問題Hadoop豬

UDF(test.py),

@outputSchema("cookie:chararray") 
def getSimple(): 
    return 'Hello' 

豬代碼,

register test.py using jython as TestSimple; 
a = TestSimple.getSimple() as word; 

錯誤消息,

[main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <line 1, column 0> Syntax error, unexpected symbol at or near 'a' 

在此先感謝, 林

+1

這是無效的「豬」語法。 – gobrewers14

回答

2

您需要加載一些數據而不是用你的UDF處理它。 像: 加載數據:

A = LOAD 'input' USING PigStorage('\t','-schema'); 

過程與UDF數據,假設你在你的輸入有一個ID字段:

B = FOREACH A GENERATE TestSimple.getSimple(id) as word; 

當然,你需要爲你沒有註冊你的UDF它正確。

+1

謝謝kecso! :) –