Giter Site home page Giter Site logo

hive-jdbc-storage-handler's Introduction

Hive JDBC Storage Handler

Provides support for creating read-only Hive external tables that can read the results of a query run on an RDBMS such as MySQL.

Usage

  • Clone the git project and run mvn clean package to produce the storage handler JAR.

  • Start hive and add the JAR file to the classpath:

    ADD JAR /path/to/hive-jdbc-storage-handler-1.1.1-cdh4.3.0-SNAPSHOT-dist.jar;
    
  • Create an external table in Hive:

    CREATE EXTERNAL TABLE mysql_test
    (
        id STRING,
        part_name STRING,
        warehouse_id STRING,
        created STRING
    )
    STORED BY 'com.qubitproducts.hive.storage.jdbc.JdbcStorageHandler' 
    TBLPROPERTIES (
        "qubit.sql.database.type" = "MYSQL",
        "qubit.sql.jdbc.url" = "jdbc:mysql://localhost:3306/qubit?user=qubit&password=qubit",
        "qubit.sql.jdbc.driver" = "com.mysql.jdbc.Driver",
        "qubit.sql.query" = "SELECT part_id, part_name, warehouse_id, created_datetime FROM parts",
        "qubit.sql.column.mapping" = "id=part_id, created=created_datetime:date"
    );
    

Configuration

Table Creation

Required Table Properties
  • qubit.sql.database.type - Currently only supports MYSQL, H2 and DERBY.
  • qubit.sql.jdbc.url - Full JDBC connection URL.
  • qubit.sql.jdbc.driver - JDBC driver class name.
  • qubit.sql.query - Query to run against the database. The Storage handler is intelligent enough to determine the correct conditions to apply to the database query based on the hive query being executed. As such, please ensure that there are no WHERE clauses defined here. If column names differ between the hive table and the query, use the qubit.sql.column.mapping property to define the mappings.
Optional Table Properties
  • qubit.sql.column.mapping - If the Hive column names are different from the corresponding table column, use this property to indicate it. Format is: hiveColumnName=dbColumnName[:type] separated by commas. Currently the only accepted type is date. Sample usage: "qubit.sql.column.mapping" = "id=part_id, created=created_datetime:date". Only the columns that differ need to be specified.
  • qubit.sql.jdbc.fetch.size - Resultset fetch size. Default value is 1000.
  • Connections to the database are made through a DBCP connection pool. Specify any DBCP configuration options by prefixing them with qubit.sql.dbcp.. Eg: qubit.sql.dbcp.maxActive=5

Querying

The Storage handler is intelligent enough to determine the correct conditions to apply to the database query based on the hive query being executed. Therefore no additional steps need to be performed while querying.

Resultset fetch size can be changed at query time:

SET qubit.sql.jdbc.fetch.size=500;

hive-jdbc-storage-handler's People

Contributors

charith-qubit avatar

Watchers

James Cloos avatar Li Guo avatar  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.