自動増分値を作成する Java 関数を作成し、この関数に基づいてハイブ UDF も作成しました。ハイブでうまく機能します。この関数に基づいて Impala UDF を作成したところ、自動増分整数ではなく「null」が返されました。
Java UDF コードは次のとおりです。
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.hive.ql.udf.UDFType;
@UDFType(stateful = true)
public class AutoIncrementUDF extends UDF {
int ctr;
public int evaluate() {
ctr++;
return ctr;
}
}
ハイブ UDF の作成:
create function autoincr as 'AutoIncrementUDF';
Impala UDF の作成:
create function autoincr() returns int LOCATION '/user/acombs/AutoIncrementUDF.jar' symbol='AutoIncrementUDF';
Hive と Impala での使用:
select autoincr() as testkey, * from mapfund
どんな助けでも大歓迎です!ありがとう、アンナ