Skip to content

Instantly share code, notes, and snippets.

@mwinkle
Created July 2, 2014 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwinkle/ac9dbb152a1e10e06c16 to your computer and use it in GitHub Desktop.
Save mwinkle/ac9dbb152a1e10e06c16 to your computer and use it in GitHub Desktop.
HDInsight Hive with Groovy inline UDF's
set hive.aux.jars.path=file:///c:/apps/dist/hive-0.13.0.2.1.3.0-1887/lib/groovy-all-2.1.6.jar
COMPILE `import org.apache.hadoop.hive.ql.exec.UDF \;
public class Pyth extends UDF {
public double evaluate(double a, double b){
return Math.sqrt((a*a) + (b*b)) \;
}
} ` AS GROOVY NAMED Pyth.groovy;
CREATE TEMPORARY FUNCTION Pyth as 'Pyth';
SELECT country, Pyth(3,4) from hivesampletable limit 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment