@Description( name = "hello", value = "_FUNC_(str) - from the input string" + "returns the value that is \"Hello $str\" ", extended = "Example:\n" + " > SELECT _FUNC_(str) FROM src;" ) public class MyUDF extends UDF {
private static final Logger logger = LoggerFactory.getLogger(MyUDF.class);
hive> add jar hdfs:///user/hive/udf/bigdata-1.0-SNAPSHOT-jar-with-dependencies.jar; converting to local hdfs:///user/hive/udf/bigdata-1.0-SNAPSHOT-jar-with-dependencies.jar Added [/tmp/5aa66ab6-35ab-45d5-bef1-5acc79d16b23_resources/bigdata-1.0-SNAPSHOT-jar-with-dependencies.jar] to class path Added resources: [hdfs:///user/hive/udf/bigdata-1.0-SNAPSHOT-jar-with-dependencies.jar] hive> create temporary function my_lower as "com.bigdata.hive.MyUDF"; OK Time taken: 0.073 seconds hive> select my_lower("123"); OK Hello 123 Time taken: 0.253 seconds, Fetched: 1 row(s)
查看jar包
1 2 3
hive> list jar; /tmp/5aa66ab6-35ab-45d5-bef1-5acc79d16b23_resources/bigdata-1.0-SNAPSHOT-jar-with-dependencies.jar
删除jar包
1 2
hive> delete jar /tmp/5aa66ab6-35ab-45d5-bef1-5acc79d16b23_resources/bigdata-1.0-SNAPSHOT-jar-with-dependencies.jar;
查看function
1 2 3 4 5
hive> show functions like '*lower'; OK lower Time taken: 0.016 seconds, Fetched: 1 row(s)