Last active
June 22, 2018 07:36
-
-
Save yssharma/4368970 to your computer and use it in GitHub Desktop.
Hive Auto increment UDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.confusedcoders.hive.udf; | |
| import org.apache.hadoop.hive.ql.exec.UDF; | |
| public class AutoIncrUdf extends UDF{ | |
| int lastValue; | |
| public int evaluate() { | |
| lastValue++; | |
| return lastValue; | |
| } | |
| } |
This did not work for me even I add the class annotation:
@UDFType(stateful = true)
Also in addition to "statefull=true" you need to set mapper=1 , otherqise the desired output will not come.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This did not work for me until I added a class annotation:
@UDFType(stateful = true)
public class AutoIncrUdf extends UDF {
...
}