Giter VIP home page Giter VIP logo

hiveudf's Introduction

Apache Hive UDF Repository

A list of user defined functions are collected here for Hive and Spark SQL.

Note:

  • UDAF class is deprecated will move to generic interface.

For Development:

  1. Build the JAR:

    mvn package
    
  2. Start Hive CLI with the JAR in your classpath:

    export HADOOP_CLASSPATH=target/df-hiveudf-1.0-SNAPSHOT.jar ; hive
    
  3. Execute:

    create temporary function str_lower as 'com.datafibers.hiveudf.udf.StringLower';
    
  4. Execute:

    select str_lower("UPPER CASE LETTERS");
    

For Deployment:

  1. In shell commandline, create a permanent function:

    hdfs dfs -mkdir /apps/hive/functions
    hdfs dfs -chown hive:hive /apps/hive/functions
    cp df-hiveudf-1.0-SNAPSHOT.jar /tmp
    hdfs dfs -put -f /tmp/df-hiveudf-1.0-SNAPSHOT.jar /apps/hive/functions
  2. In beeline, create/register/check the function

    DROP FUNCTION IF EXISTS str_lower;
    DROP FUNCTION IF EXISTS arraycontains;
    CREATE FUNCTION str_lower AS 'com.datafibers.hiveudf.udf.StringLower' USING JAR 'hdfs:////apps/hive/functions/df-hiveudf-1.0-SNAPSHOT.jar';
    CREATE FUNCTION arraycontains AS 'com.datafibers.hiveudf.gudf.ArrayContains' USING JAR 'hdfs:////apps/hive/functions/df-hiveudf-1.0-SNAPSHOT.jar';
    DESC FUNCTION arraycontains;
    DESC FUNCTION EXTENDED arraycontains;
  3. After that, you can use the functions like hive build-in functions.

    select str_lower(name), work_place from employee where arraycontains(work_place, 'Toronto');
  4. Check query explain

    explain select str_lower(name), work_place from employee where arraycontains(work_place, 'Toronto');

For Streaming Function

For streaming function by python, follow steps below.

hdfs dfs -mkdir /apps/hive/scripts
hdfs dfs -put hive_udf_addfile.py /apps/hive/scripts
hive -f hive_udf_addfile.sql

hiveudf's People

Contributors

willddy avatar datafibers avatar

Watchers

 avatar Zonqing avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.