Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Hive client using the Apache Thrift RPC system
JavaScript Other
tree: 89d59e8832

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
samples
src/0.7.1-cdh3u2
.gitignore
README.md
index.js

README.md

Thrift Hive - Hive client using the Apache Thrift RPC system.

The project export the Hive API throught Thrift. Multiple versions of hive are supported.

The only function added to the generated Thrift code is hive.createClient. It take an options object as its argument and return an object with the following properties:

  • client
    A reference to the hive client returned by thrift.createClient
  • connection
    A reference to the hive connection returned by thrift.createConnection
  • end([callback])
    Close the Thrift connection
  • execute(query, [callback])
    Execute a query
  • query(query, [size], [callback])
    Execute a query and return its results as an array of arrays (rows and columns)

Hive connection: sugar example

    var hive = require('thrift-hive');
    // Client connection
    var client = hive.createClient({
        version: '0.7.1-cdh3u2'
        server: '127.0.0.1'
        port: 10000
        timeout: 1000
    });
    // Execute query
    client.query('show databases', function(err, databases){
        assert.ifError(err);
        console.log(databases);
        client.end();
    });

Hive connection: raw example

    var thrift     = require('thrift');
    var transport = require('thrift/transport');
    var ThriftHive = require('thrift-hive/0.7.1-cdh3u2/ThriftHive');
    // Client connection
    var options = {transport: transport.TBufferedTransport, timeout: 1000};
    var connection = thrift.createConnection('127.0.0.1', 10000, options);
    var client = thrift.createClient(ThriftHive, connection);
    // Execute with fetchAll
    client.execute('show databases', function(err){
        assert.ifError(err);
        client.fetchAll(function(err, databases){
            assert.ifError(err);
            console.log(databases);
            connection.end();
        });
    });
Something went wrong with that request. Please try again.